From 220f6b4d73793c57ba6f9023b8d38d171f342a7e Mon Sep 17 00:00:00 2001 From: dkaraush Date: Wed, 15 Nov 2023 16:23:35 +0400 Subject: [PATCH] update to 10.2.9 (4087) --- .../jni/tgnet/ConnectionsManager.cpp | 7 +- TMessagesProj/src/main/assets/arctic.attheme | 4 +- TMessagesProj/src/main/assets/day.attheme | 4 +- TMessagesProj/src/main/assets/night.attheme | 2 +- .../org/telegram/messenger/BuildVars.java | 4 +- .../telegram/messenger/CodeHighlighting.java | 22 +- .../java/org/telegram/messenger/FileLog.java | 7 +- .../messenger/MediaDataController.java | 39 ++- .../org/telegram/messenger/MessageObject.java | 20 +- .../messenger/MessagesController.java | 17 +- .../telegram/messenger/MessagesStorage.java | 35 ++- .../telegram/ui/ActionBar/SimpleTextView.java | 6 + .../java/org/telegram/ui/ActionBar/Theme.java | 3 + .../telegram/ui/ActionBar/ThemeColors.java | 8 +- .../telegram/ui/Adapters/DialogsAdapter.java | 2 +- .../java/org/telegram/ui/ArticleViewer.java | 6 +- .../telegram/ui/Cells/ChatMessageCell.java | 16 +- .../org/telegram/ui/Cells/DialogCell.java | 2 +- .../telegram/ui/Cells/PhotoEditToolCell.java | 2 +- .../telegram/ui/Cells/StickerSetNameCell.java | 2 +- .../java/org/telegram/ui/ChatActivity.java | 27 +- .../org/telegram/ui/ChatEditActivity.java | 26 +- .../telegram/ui/Components/AlertsCreator.java | 49 +++- .../Components/AvatarConstructorFragment.java | 4 +- .../ui/Components/BotWebViewSheet.java | 10 +- .../ui/Components/CaptionPhotoViewer.java | 2 +- .../ui/Components/ChatActivityEnterView.java | 57 +++-- .../ui/Components/ChatAttachAlert.java | 6 +- .../ChatAttachAlertBotWebViewLayout.java | 10 +- .../ChatAttachAlertPhotoLayout.java | 10 + .../ui/Components/Crop/CropRotationWheel.java | 4 +- .../ui/Components/EditTextBoldCursor.java | 10 +- .../ui/Components/EditTextEffects.java | 22 +- .../ui/Components/EmojiTabsStrip.java | 58 +++-- .../org/telegram/ui/Components/EmojiView.java | 241 +++++++++++------- .../telegram/ui/Components/PhotoCropView.java | 2 +- .../ui/Components/PhotoFilterView.java | 30 +-- .../PhotoViewerCaptionEnterView.java | 4 +- .../Premium/LimitReachedBottomSheet.java | 2 +- .../Premium/boosts/BoostDialogs.java | 20 +- .../Premium/boosts/BoostPagerBottomSheet.java | 4 +- .../boosts/BoostViaGiftsBottomSheet.java | 28 +- .../boosts/ReassignBoostBottomSheet.java | 8 +- .../Premium/boosts/SelectorBottomSheet.java | 79 ++++-- .../boosts/cells/msg/GiveawayMessageCell.java | 43 +++- .../ui/Components/ReplyMessageLine.java | 13 +- .../java/org/telegram/ui/DialogsActivity.java | 2 +- .../java/org/telegram/ui/LaunchActivity.java | 14 +- .../org/telegram/ui/PaymentFormActivity.java | 2 + .../java/org/telegram/ui/PhotoViewer.java | 26 +- .../ui/SelectAnimatedEmojiDialog.java | 132 +++++++++- .../org/telegram/ui/StatisticActivity.java | 5 + .../ui/Stories/DarkThemeResourceProvider.java | 2 +- .../telegram/ui/Stories/PeerStoriesView.java | 12 +- .../ui/Stories/StoryPositionView.java | 4 +- .../recorder/CaptionContainerView.java | 4 +- .../ui/Stories/recorder/EmojiBottomSheet.java | 8 +- .../ui/TextMessageEnterTransition.java | 2 +- TMessagesProj/src/main/res/values/strings.xml | 13 +- gradle.properties | 4 +- 60 files changed, 848 insertions(+), 359 deletions(-) diff --git a/TMessagesProj/jni/tgnet/ConnectionsManager.cpp b/TMessagesProj/jni/tgnet/ConnectionsManager.cpp index 6faff76dfd..8df45c39e0 100644 --- a/TMessagesProj/jni/tgnet/ConnectionsManager.cpp +++ b/TMessagesProj/jni/tgnet/ConnectionsManager.cpp @@ -2256,7 +2256,9 @@ void ConnectionsManager::processRequestQueue(uint32_t connectionTypes, uint32_t switch (request->connectionType & 0x0000ffff) { case ConnectionTypeGeneric: - genericRunningRequestCount++; + if (!request->failedByFloodWait) { + genericRunningRequestCount++; + } break; case ConnectionTypeDownload: { auto map = request->isCancelRequest() ? downloadCancelRunningRequestCount : downloadRunningRequestCount; @@ -2593,7 +2595,8 @@ void ConnectionsManager::processRequestQueue(uint32_t connectionTypes, uint32_t case ConnectionTypeGenericMedia: if (!canUseUnboundKey && genericRunningRequestCount >= 60) { iter++; - DEBUG_D("skip queue, token = %d: generic type: running generic requests >= 60", request->requestToken); + if (LOGS_ENABLED) + DEBUG_D("skip queue, token = %d: generic type: running generic requests >= 60", request->requestToken); continue; } genericRunningRequestCount++; diff --git a/TMessagesProj/src/main/assets/arctic.attheme b/TMessagesProj/src/main/assets/arctic.attheme index a385f6148c..54b63c53c5 100644 --- a/TMessagesProj/src/main/assets/arctic.attheme +++ b/TMessagesProj/src/main/assets/arctic.attheme @@ -132,7 +132,7 @@ chat_outViewsSelected=-1258291201 chat_outInstant=-1 actionBarDefaultSearchPlaceholder=-2005173381 chat_outForwardedNameText=-1 -dialogRoundCheckBox=-15033089 +dialogRoundCheckBox=-13653259 actionBarTabLine=-13655305 chats_nameMessageArchived_threeLines=-7237231 chat_outSiteNameText=-1 @@ -251,7 +251,6 @@ inappPlayerClose=-7563878 chat_outMediaIcon=-13332255 chat_outAudioCacheSeekbar=738197503 chats_sentClock=2066650878 -dialogFloatingButton=-15033089 chats_archiveBackground=-11294989 chat_inPreviewInstantText=-15299362 chat_outLoaderSelected=-1 @@ -281,3 +280,4 @@ chat_outReplyMediaMessageSelectedText=-1056964609 chat_serviceText=-1 chats_attachMessage=-13268780 chat_outSentClock=1895825407 +chat_editMediaButton=-15033089 \ No newline at end of file diff --git a/TMessagesProj/src/main/assets/day.attheme b/TMessagesProj/src/main/assets/day.attheme index 861fbd3ae0..0cf087be54 100644 --- a/TMessagesProj/src/main/assets/day.attheme +++ b/TMessagesProj/src/main/assets/day.attheme @@ -142,7 +142,7 @@ chat_outViewsSelected=-3676417 chat_outInstant=-1 actionBarDefaultSearchPlaceholder=-2005173381 chat_outForwardedNameText=-1 -dialogRoundCheckBox=-15033089 +dialogRoundCheckBox=-13653259 actionBarTabLine=-13655305 chats_nameMessageArchived_threeLines=-7237231 chat_outSiteNameText=-1 @@ -272,7 +272,6 @@ chat_outMediaIcon=-14707997 chat_outAudioCacheSeekbar=738197503 chats_sentClock=2073474246 chat_inAudioSeekbar=-2762017 -dialogFloatingButton=-15033089 chats_archiveBackground=-11294989 chat_inPreviewInstantText=-15300135 chat_inViews=-274882397 @@ -306,3 +305,4 @@ chat_outReplyMediaMessageSelectedText=-3676417 chat_serviceText=-13092808 chats_attachMessage=-14321214 chat_outSentClock=1895825407 +chat_editMediaButton=-15033089 \ No newline at end of file diff --git a/TMessagesProj/src/main/assets/night.attheme b/TMessagesProj/src/main/assets/night.attheme index 4e2cdb2b02..1a394741d4 100644 --- a/TMessagesProj/src/main/assets/night.attheme +++ b/TMessagesProj/src/main/assets/night.attheme @@ -214,7 +214,7 @@ actionBarDefaultSearchPlaceholder=-2097152001 profile_tabSelector=268435455 actionBarActionModeDefaultSelector=520093695 chat_outForwardedNameText=-5448193 -dialogRoundCheckBox=-15033089 +dialogRoundCheckBox=-10177041 chat_emojiPanelTrendingTitle=-1 actionBarTabLine=-12339201 chat_stickersHintPanel=-14606046 diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index a7fab26c70..dc75af5f0b 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -24,8 +24,8 @@ public class BuildVars { public static boolean USE_CLOUD_STRINGS = true; public static boolean CHECK_UPDATES = true; public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29; - public static int BUILD_VERSION = 4082; - public static String BUILD_VERSION_STRING = "10.2.6"; + public static int BUILD_VERSION = 4087; + public static String BUILD_VERSION_STRING = "10.2.9"; public static int APP_ID = 4; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/CodeHighlighting.java b/TMessagesProj/src/main/java/org/telegram/messenger/CodeHighlighting.java index 6d1db01560..91c576f8d8 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/CodeHighlighting.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/CodeHighlighting.java @@ -214,7 +214,7 @@ public static void highlight(Spannable text, int start, int end, String lng, int long S = System.currentTimeMillis(); final StringToken[][] tokens = new StringToken[1][]; try { - tokens[0] = tokenize(text.subSequence(start, end).toString(), compiledPatterns == null ? null : compiledPatterns.get(lng)).toArray(); + tokens[0] = tokenize(text.subSequence(start, end).toString(), compiledPatterns == null ? null : compiledPatterns.get(lng), 0).toArray(); } catch (Exception e) { FileLog.e(e); } @@ -289,15 +289,15 @@ public CachedToSpan(int group, int start, int end) { } } - private static LinkedList tokenize(String text, TokenPattern[] grammar) { - return tokenize(text, grammar, null); + private static LinkedList tokenize(String text, TokenPattern[] grammar, int depth) { + return tokenize(text, grammar, null, depth); } - private static LinkedList tokenize(String text, TokenPattern[] grammar, TokenPattern ignorePattern) { + private static LinkedList tokenize(String text, TokenPattern[] grammar, TokenPattern ignorePattern, int depth) { LinkedList list = new LinkedList(); list.addAfter(list.head, new StringToken(text)); grammar = flatRest(grammar); - matchGrammar(text, list, grammar, list.head, 0, null, ignorePattern); + matchGrammar(text, list, grammar, list.head, 0, null, ignorePattern, depth); return list; } @@ -327,8 +327,8 @@ private static TokenPattern[] flatRest(TokenPattern[] patterns) { return patterns; } - private static void matchGrammar(String text, LinkedList tokenList, TokenPattern[] grammar, Node startNode, int startPos, RematchOptions rematch, TokenPattern ignorePattern) { - if (grammar == null) { + private static void matchGrammar(String text, LinkedList tokenList, TokenPattern[] grammar, Node startNode, int startPos, RematchOptions rematch, TokenPattern ignorePattern, int depth) { + if (grammar == null || depth > 20) { return; } for (TokenPattern pattern : grammar) { @@ -420,9 +420,9 @@ private static void matchGrammar(String text, LinkedList tokenList, TokenPattern StringToken wrapped; if (pattern.insideTokenPatterns != null) { - wrapped = new StringToken(pattern.group, tokenize(match.string, pattern.insideTokenPatterns), match.length); + wrapped = new StringToken(pattern.group, tokenize(match.string, pattern.insideTokenPatterns, depth + 1), match.length); } else if (pattern.insideLanguage != null) { - wrapped = new StringToken(pattern.group, tokenize(match.string, compiledPatterns.get(pattern.insideLanguage), pattern), match.length); + wrapped = new StringToken(pattern.group, tokenize(match.string, compiledPatterns.get(pattern.insideLanguage), pattern, depth + 1), match.length); } else { wrapped = new StringToken(pattern.group, match.string); } @@ -436,7 +436,7 @@ private static void matchGrammar(String text, LinkedList tokenList, TokenPattern RematchOptions nestedRematch = new RematchOptions(); nestedRematch.cause = pattern; nestedRematch.reach = reach; - matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch, ignorePattern); + matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch, ignorePattern, depth + 1); if (rematch != null && nestedRematch.reach > rematch.reach) { rematch.reach = nestedRematch.reach; @@ -447,7 +447,7 @@ private static void matchGrammar(String text, LinkedList tokenList, TokenPattern } private static Match matchPattern(TokenPattern pattern, int pos, String text) { - Matcher matcher = pattern.pattern.getPattern().matcher(text); + Matcher matcher = pattern.pattern.getPattern(). matcher(text); matcher.region(pos, text.length()); if (!matcher.find()) { return null; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java index 8d16ba57c8..b5cac6c331 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java @@ -126,7 +126,7 @@ public static void dumpUnparsedMessage(TLObject message, long messageId) { try { checkGson(); getInstance().dateFormat.format(System.currentTimeMillis()); - String messageStr = "receive message -> " + message.getClass().getSimpleName() + " : " + gson.toJson(message); + String messageStr = "receive message -> " + message.getClass().getSimpleName() + " : " + (gsonDisabled ? message : gson.toJson(message)); String res = "null"; long time = System.currentTimeMillis(); FileLog.getInstance().logQueue.postRunnable(() -> { @@ -150,6 +150,11 @@ public static void dumpUnparsedMessage(TLObject message, long messageId) { } } + private static boolean gsonDisabled; + public static void disableGson(boolean disable) { + gsonDisabled = disable; + } + private static void checkGson() { if (gson == null) { HashSet privateFields = new HashSet<>(); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java index bce7adc6b7..55e6b24b86 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java @@ -144,6 +144,7 @@ public MediaDataController(int num) { } else { draftPreferences = ApplicationLoader.applicationContext.getSharedPreferences("drafts" + currentAccount, Activity.MODE_PRIVATE); } + final ArrayList replyMessageOwners = new ArrayList<>(); Map values = draftPreferences.getAll(); for (Map.Entry entry : values.entrySet()) { try { @@ -163,6 +164,9 @@ public MediaDataController(int num) { } int threadId = isThread ? Utilities.parseInt(key.substring(key.lastIndexOf('_') + 1)) : 0; threads.put(threadId, message); + if (message.reply_to != null) { + replyMessageOwners.add(message); + } } } else { TLRPC.DraftMessage draftMessage = TLRPC.DraftMessage.TLdeserialize(serializedData, serializedData.readInt32(true), true); @@ -181,6 +185,7 @@ public MediaDataController(int num) { //igonre } } + loadRepliesOfDraftReplies(replyMessageOwners); loadStickersByEmojiOrName(AndroidUtilities.STICKERS_PLACEHOLDER_PACK_NAME, false, true); loadEmojiThemes(); @@ -192,6 +197,30 @@ public MediaDataController(int num) { menuBotsUpdateDate = getMessagesController().getMainSettings().getInt("menuBotsUpdateDate", 0); } + private void loadRepliesOfDraftReplies(final ArrayList messages) { + if (messages == null || messages.isEmpty()) { + return; + } + getMessagesStorage().getStorageQueue().postRunnable(() -> { + try { + ArrayList usersToLoad = new ArrayList<>(); + ArrayList chatsToLoad = new ArrayList<>(); + LongSparseArray>> replyMessageOwners = new LongSparseArray<>(); + LongSparseArray> dialogReplyMessagesIds = new LongSparseArray<>(); + for (int i = 0; i < messages.size(); ++i) { + try { + MessagesStorage.addReplyMessages(messages.get(i), replyMessageOwners, dialogReplyMessagesIds); + } catch (Exception e) { + getMessagesStorage().checkSQLException(e); + } + } + getMessagesStorage().loadReplyMessages(replyMessageOwners, dialogReplyMessagesIds, usersToLoad, chatsToLoad, false); + } catch (Exception e) { + FileLog.e(e); + } + }); + } + public static final int TYPE_IMAGE = 0; public static final int TYPE_MASK = 1; public static final int TYPE_FAVE = 2; @@ -6641,12 +6670,12 @@ public void saveDraft(long dialogId, int threadId, CharSequence message, ArrayLi if (quote != null) { draftMessage.reply_to.quote_text = quote.getText(); if (draftMessage.reply_to.quote_text != null) { - draftMessage.reply_to.flags |= 64; + draftMessage.reply_to.flags |= 4; } draftMessage.reply_to.quote_entities = quote.getEntities(); if (draftMessage.reply_to.quote_entities != null && !draftMessage.reply_to.quote_entities.isEmpty()) { draftMessage.reply_to.quote_entities = new ArrayList<>(draftMessage.reply_to.quote_entities); - draftMessage.reply_to.flags |= 128; + draftMessage.reply_to.flags |= 8; } if (quote.message != null && quote.message.messageOwner != null) { TLRPC.Peer peer2 = getMessagesController().getPeer(dialogId); @@ -6826,9 +6855,9 @@ public void saveDraft(long dialogId, int threadId, TLRPC.DraftMessage draft, TLR if (threads != null) { replyToMessage = threads.get(threadId); } - if (replyToMessage == null || replyToMessage.id != draft.reply_to.reply_to_msg_id || !MessageObject.peersEqual(draft.reply_to.reply_to_peer_id, replyToMessage.peer_id)) { - replyToMessage = null; - } +// if (replyToMessage == null || replyToMessage.id != draft.reply_to.reply_to_msg_id || !MessageObject.peersEqual(draft.reply_to.reply_to_peer_id, replyToMessage.peer_id)) { +// replyToMessage = null; +// } } else if (draft != null && draft.reply_to == null) { replyToMessage = null; } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java index ea2f5d3611..36958d2e20 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java @@ -689,8 +689,8 @@ public static class TextLayoutBlock { public Drawable copySelector; public Paint copySeparator; - public void layoutCode(String lng, int codeLength) { - hasCodeCopyButton = codeLength >= 75; + public void layoutCode(String lng, int codeLength, boolean noforwards) { + hasCodeCopyButton = codeLength >= 75 && !noforwards; if (hasCodeCopyButton) { copyText = new Text(LocaleController.getString(R.string.CopyCode).toUpperCase(), SharedConfig.fontSize - 3, AndroidUtilities.getTypeface(AndroidUtilities.TYPEFACE_ROBOTO_MEDIUM)); copyIcon = ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.msg_copy).mutate(); @@ -4210,7 +4210,7 @@ private void updateMessageText(AbstractMap users, AbstractMap< } else if (!isMediaEmpty()) { // messageText = getMediaTitle(getMedia(messageOwner)); // I'm afraid doing this if (getMedia(messageOwner) instanceof TLRPC.TL_messageMediaGiveaway) { - messageText = LocaleController.getString("BoostingGiveaway", R.string.BoostingGiveaway); + messageText = LocaleController.getString("BoostingGiveawayChannelStarted", R.string.BoostingGiveawayChannelStarted); } else if (getMedia(messageOwner) instanceof TLRPC.TL_messageMediaStory) { if (getMedia(messageOwner).via_mention) { TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(getMedia(messageOwner).user_id); @@ -6036,6 +6036,11 @@ public void generateLayout(TLRPC.User fromUser) { return; } boolean hasUrls = applyEntities(); + boolean noforwards = messageOwner != null && messageOwner.noforwards; + if (!noforwards) { + TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-getDialogId()); + noforwards = chat != null && chat.noforwards; + } textLayoutBlocks = new ArrayList<>(); textWidth = 0; @@ -6184,7 +6189,7 @@ public void generateLayout(TLRPC.User fromUser) { block.padBottom = dp(7); } } else if (block.code) { - block.layoutCode(range.language, range.end - range.start); + block.layoutCode(range.language, range.end - range.start, noforwards); block.padTop = dp(4) + block.languageHeight + (block.first ? 0 : dp(5)); block.padBottom = dp(4) + (block.last ? 0 : dp(7)) + (block.hasCodeCopyButton ? dp(38) : 0); } @@ -6459,6 +6464,11 @@ public static class TextLayoutBlocks { public TextLayoutBlocks(MessageObject messageObject, @NonNull CharSequence text, TextPaint textPaint, int width) { this.text = text; textWidth = 0; + boolean noforwards = messageObject != null && messageObject.messageOwner != null && messageObject.messageOwner.noforwards; + if (messageObject != null && !noforwards) { + TLRPC.Chat chat = MessagesController.getInstance(messageObject.currentAccount).getChat(-messageObject.getDialogId()); + noforwards = chat != null && chat.noforwards; + } hasCode = text instanceof Spanned && ((Spanned) text).getSpans(0, text.length(), CodeHighlighting.Span.class).length > 0; hasQuote = text instanceof Spanned && ((Spanned) text).getSpans(0, text.length(), QuoteSpan.QuoteStyleSpan.class).length > 0; @@ -6581,7 +6591,7 @@ public TextLayoutBlocks(MessageObject messageObject, @NonNull CharSequence text, block.padBottom = dp(7); } } else if (block.code) { - block.layoutCode(range.language, range.end - range.start); + block.layoutCode(range.language, range.end - range.start, noforwards); block.padTop = dp(4) + block.languageHeight + (block.first ? 0 : dp(5)); block.padBottom = dp(4) + (block.last ? 0 : dp(7)) + (block.hasCodeCopyButton ? dp(38) : 0); } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java index a73a9803f9..c6b72c4af8 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java @@ -5243,6 +5243,9 @@ protected void clearFullUsers() { loadedFullChats.clear(); } + private final LongSparseArray peerDialogsRequested = new LongSparseArray(); + private final long peerDialogRequestTimeout = 1000 * 60 * 4; + private void reloadDialogsReadValue(ArrayList dialogs, long did) { if (did == 0 && (dialogs == null || dialogs.isEmpty())) { return; @@ -5256,7 +5259,12 @@ private void reloadDialogsReadValue(ArrayList dialogs, long did) { } TLRPC.TL_inputDialogPeer inputDialogPeer = new TLRPC.TL_inputDialogPeer(); inputDialogPeer.peer = inputPeer; - req.peers.add(inputDialogPeer); + final long _did = DialogObject.getPeerDialogId(inputPeer); + Long lastRequest = peerDialogsRequested.get(_did); + if (lastRequest == null || System.currentTimeMillis() - lastRequest > peerDialogRequestTimeout) { + req.peers.add(inputDialogPeer); + peerDialogsRequested.put(_did, System.currentTimeMillis()); + } } } else { TLRPC.InputPeer inputPeer = getInputPeer(did); @@ -5265,7 +5273,12 @@ private void reloadDialogsReadValue(ArrayList dialogs, long did) { } TLRPC.TL_inputDialogPeer inputDialogPeer = new TLRPC.TL_inputDialogPeer(); inputDialogPeer.peer = inputPeer; - req.peers.add(inputDialogPeer); + final long _did = DialogObject.getPeerDialogId(inputPeer); + Long lastRequest = peerDialogsRequested.get(_did); + if (lastRequest == null || System.currentTimeMillis() - lastRequest > peerDialogRequestTimeout) { + req.peers.add(inputDialogPeer); + peerDialogsRequested.put(_did, System.currentTimeMillis()); + } } if (req.peers.isEmpty()) { return; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java index f238a4778e..09760b7854 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java @@ -10379,6 +10379,7 @@ private void putMessagesInternal(ArrayList messages, boolean with SQLitePreparedStatement state_tasks = null; SQLitePreparedStatement state_dialogs_replace = null; SQLitePreparedStatement state_dialogs_update = null; + SQLitePreparedStatement state_dialogs_update_without_message = null; SQLitePreparedStatement state_topics_update = null; SQLitePreparedStatement state_media_topics = null; SQLiteCursor cursor = null; @@ -11204,6 +11205,7 @@ private void putMessagesInternal(ArrayList messages, boolean with state_dialogs_replace = database.executeFast("REPLACE INTO dialogs VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); state_dialogs_update = database.executeFast("UPDATE dialogs SET date = ?, unread_count = ?, last_mid = ?, last_mid_group = ?, unread_count_i = ? WHERE did = ?"); + state_dialogs_update_without_message = database.executeFast("UPDATE dialogs SET unread_count = ?, unread_count_i = ? WHERE did = ?"); state_topics_update = database.executeFast("UPDATE topics SET unread_count = ?, top_message = ?, unread_mentions = ?, total_messages_count = ? WHERE did = ? AND topic_id = ?"); ArrayList dids = new ArrayList<>(); @@ -11262,18 +11264,26 @@ private void putMessagesInternal(ArrayList messages, boolean with dids.add(key); if (exists) { - state_dialogs_update.requery(); - state_dialogs_update.bindInteger(1, message != null && (!doNotUpdateDialogDate || dialog_date == 0) ? message.date : dialog_date); - state_dialogs_update.bindInteger(2, old_unread_count + unread_count); - state_dialogs_update.bindInteger(3, messageId); - if (message != null && (message.flags & 131072) != 0) { - state_dialogs_update.bindLong(4, message.grouped_id); + if (messageId >= last_mid || DialogObject.isEncryptedDialog(key)) { + state_dialogs_update.requery(); + state_dialogs_update.bindInteger(1, message != null && (!doNotUpdateDialogDate || dialog_date == 0) ? message.date : dialog_date); + state_dialogs_update.bindInteger(2, old_unread_count + unread_count); + state_dialogs_update.bindInteger(3, messageId); + if (message != null && (message.flags & 131072) != 0) { + state_dialogs_update.bindLong(4, message.grouped_id); + } else { + state_dialogs_update.bindNull(4); + } + state_dialogs_update.bindInteger(5, old_mentions_count + mentions_count); + state_dialogs_update.bindLong(6, key); + state_dialogs_update.step(); } else { - state_dialogs_update.bindNull(4); + state_dialogs_update_without_message.requery(); + state_dialogs_update_without_message.bindInteger(1, old_unread_count + unread_count); + state_dialogs_update_without_message.bindInteger(2, old_mentions_count + mentions_count); + state_dialogs_update_without_message.bindLong(3, key); + state_dialogs_update_without_message.step(); } - state_dialogs_update.bindInteger(5, old_mentions_count + mentions_count); - state_dialogs_update.bindLong(6, key); - state_dialogs_update.step(); } else { state_dialogs_replace.requery(); state_dialogs_replace.bindLong(1, key); @@ -11303,6 +11313,8 @@ private void putMessagesInternal(ArrayList messages, boolean with } state_dialogs_update.dispose(); state_dialogs_update = null; + state_dialogs_update_without_message.dispose(); + state_dialogs_update_without_message = null; state_dialogs_replace.dispose(); state_dialogs_replace = null; @@ -11531,6 +11543,9 @@ private void putMessagesInternal(ArrayList messages, boolean with if (state_dialogs_update != null) { state_dialogs_update.dispose(); } + if (state_dialogs_update_without_message != null) { + state_dialogs_update_without_message.dispose(); + } if (state_topics_update != null) { state_topics_update.dispose(); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/SimpleTextView.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/SimpleTextView.java index 70c02ca0a0..d58d58a22c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/SimpleTextView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/SimpleTextView.java @@ -480,6 +480,12 @@ public int getTextWidth() { return textWidth; } + public int getRightDrawableWidth() { + if (rightDrawable == null) + return 0; + return (int) (drawablePadding + rightDrawable.getIntrinsicWidth() * rightDrawableScale); + } + public int getTextHeight() { return textHeight; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java index 08247e7050..4f9aecb94e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java @@ -3888,6 +3888,7 @@ public void run() { public static final int key_chat_TextSelectionCursor = colorsCount++; public static final int key_chat_inBubbleLocationPlaceholder = colorsCount++; public static final int key_chat_BlurAlpha = colorsCount++; + public static final int key_chat_editMediaButton = colorsCount++; public static final int key_voipgroup_listSelector = colorsCount++; public static final int key_voipgroup_inviteMembersBackground = colorsCount++; @@ -4323,6 +4324,8 @@ public void run() { fallbackKeys.put(key_chat_outPollCorrectAnswer, key_chat_attachLocationBackground); fallbackKeys.put(key_chat_inPollWrongAnswer, key_chat_attachAudioBackground); fallbackKeys.put(key_chat_outPollWrongAnswer, key_chat_attachAudioBackground); + fallbackKeys.put(key_chat_editMediaButton, key_dialogFloatingButton); + fallbackKeys.put(key_chat_attachCheckBoxBackground, key_dialogRoundCheckBox); fallbackKeys.put(key_profile_tabText, key_windowBackgroundWhiteGrayText); fallbackKeys.put(key_profile_tabSelectedText, key_windowBackgroundWhiteBlueHeader); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ThemeColors.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ThemeColors.java index 08de3d77d0..a393687863 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ThemeColors.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ThemeColors.java @@ -47,7 +47,7 @@ public static int[] createDefaultColors() { defaultColors[key_dialogButton] = 0xff4991cc; defaultColors[key_dialogButtonSelector] = 0x0f000000; defaultColors[key_dialogScrollGlow] = 0xfff5f6f7; - defaultColors[key_dialogRoundCheckBox] = 0xff1A9CFF; + defaultColors[key_dialogRoundCheckBox] = 0xff4cb4f5; defaultColors[key_dialogRoundCheckBoxCheck] = 0xffffffff; defaultColors[key_dialogCameraIcon] = 0xffffffff; defaultColors[key_dialog_inlineProgressBackground] = 0xf6f0f2f5; @@ -56,7 +56,7 @@ public static int[] createDefaultColors() { defaultColors[key_dialogSearchHint] = 0xff98a0a7; defaultColors[key_dialogSearchIcon] = 0xffa1a8af; defaultColors[key_dialogSearchText] = 0xff222222; - defaultColors[key_dialogFloatingButton] = 0xff1A9CFF; + defaultColors[key_dialogFloatingButton] = 0xff4cb4f5; defaultColors[key_dialogFloatingButtonPressed] = 0x0f000000; defaultColors[key_dialogFloatingIcon] = 0xffffffff; defaultColors[key_dialogShadowLine] = 0x12000000; @@ -252,7 +252,7 @@ public static int[] createDefaultColors() { defaultColors[key_chats_archivePullDownBackgroundActive] = 0xff66a9e0; defaultColors[key_chat_attachCheckBoxCheck] = 0xffffffff; - defaultColors[key_chat_attachCheckBoxBackground] = 0xff39b2f7; + defaultColors[key_chat_attachCheckBoxBackground] = 0xff4cb4f5; defaultColors[key_chat_attachPhotoBackground] = 0x0c000000; defaultColors[key_chat_attachActiveTab] = 0xff33a7f5; defaultColors[key_chat_attachUnactiveTab] = 0xff92999e; @@ -637,6 +637,7 @@ public static int[] createDefaultColors() { defaultColors[key_chat_outBubbleLocationPlaceholder] = 0x1e307311; defaultColors[key_chat_inBubbleLocationPlaceholder] = 0x1e506373; defaultColors[key_chat_BlurAlpha] = 0xFF000000; + defaultColors[key_chat_editMediaButton] = 0xff1A9CFF; defaultColors[key_statisticChartSignature] = 0x7f252529; defaultColors[key_statisticChartSignatureAlpha] = 0x7f252529; @@ -1308,6 +1309,7 @@ public static SparseArray createColorKeysMap() { colorKeysMap.put(key_chat_inBubbleLocationPlaceholder, "chat_inBubbleLocationPlaceholder"); colorKeysMap.put(key_chat_outBubbleLocationPlaceholder, "chat_outBubbleLocationPlaceholder"); colorKeysMap.put(key_chat_BlurAlpha, "chat_BlurAlpha"); + colorKeysMap.put(key_chat_editMediaButton, "chat_editMediaButton"); colorKeysMap.put(key_voipgroup_listSelector, "voipgroup_listSelector"); colorKeysMap.put(key_voipgroup_inviteMembersBackground, "voipgroup_inviteMembersBackground"); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java index e12a678032..d5278dd5d8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java @@ -464,7 +464,7 @@ public void updateHasHints() { boolean isCalculatingDiff; boolean updateListPending; - private final static boolean ALLOW_UPDATE_IN_BACKGROUND = BuildVars.DEBUG_VERSION; + private final static boolean ALLOW_UPDATE_IN_BACKGROUND = BuildVars.DEBUG_PRIVATE_VERSION; public void updateList(Runnable saveScrollPosition) { if (isCalculatingDiff) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java index 8f233282a2..a518f2a762 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java @@ -11671,10 +11671,14 @@ public void onClose() { @Override public void onReleasePlayerBeforeClose(int photoIndex) { + TLRPC.PageBlock pageBlock = null; + if (photoIndex >= 0 && photoIndex < pageBlocks.size()) { + pageBlock = pageBlocks.get(photoIndex); + } VideoPlayer player = PhotoViewer.getInstance().getVideoPlayer(); TextureView textureView = PhotoViewer.getInstance().getVideoTextureView(); SurfaceView surfaceView = PhotoViewer.getInstance().getVideoSurfaceView(); - BlockVideoCell videoCell = getViewFromListView(listView[0], pageBlocks.get(photoIndex)); + BlockVideoCell videoCell = getViewFromListView(listView[0], pageBlock); if (videoCell != null && player != null && textureView != null) { videoCell.playFrom = player.getCurrentPosition(); videoCell.firstFrameRendered = false; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java index 1a5b9c4070..5845d4666c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -5719,6 +5719,7 @@ private void setMessageContent(MessageObject messageObject, MessageObject.Groupe currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 90); photoParentObject = document; documentAttach = document; + isSmallImage = smallImage = false; documentAttachType = DOCUMENT_ATTACH_TYPE_ROUND; } else if (MessageObject.isGifDocument(document, messageObject.hasValidGroupId())) { if (!messageObject.isGame() && !SharedConfig.isAutoplayGifs()) { @@ -5807,6 +5808,7 @@ private void setMessageContent(MessageObject messageObject, MessageObject.Groupe } } documentAttach = document; + isSmallImage = smallImage = false; documentAttachType = DOCUMENT_ATTACH_TYPE_STICKER; } else if (drawInstantViewType == 6) { currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 320); @@ -5825,6 +5827,7 @@ private void setMessageContent(MessageObject messageObject, MessageObject.Groupe } } documentAttach = document; + isSmallImage = smallImage = false; documentAttachType = DOCUMENT_ATTACH_TYPE_WALLPAPER; String str = AndroidUtilities.formatFileSize(documentAttach.size); durationWidth = (int) Math.ceil(Theme.chat_durationPaint.measureText(str)); @@ -5850,6 +5853,7 @@ private void setMessageContent(MessageObject messageObject, MessageObject.Groupe currentPhotoObject.w = currentPhotoObject.h = AndroidUtilities.dp(150); } } + isSmallImage = smallImage = false; documentAttach = document; documentAttachType = DOCUMENT_ATTACH_TYPE_THEME; } else { @@ -11165,7 +11169,7 @@ public void drawLinkPreview(Canvas canvas, float alpha) { if (linkLine == null) { linkLine = new ReplyMessageLine(this); } - Theme.chat_replyNamePaint.setColor(linkLine.check(currentMessageObject, currentUser, currentChat, resourcesProvider, false)); + Theme.chat_replyNamePaint.setColor(linkLine.check(currentMessageObject, currentUser, currentChat, resourcesProvider, ReplyMessageLine.TYPE_LINK)); boolean restore = false; boolean drawInstantButtonInside = false; @@ -12131,7 +12135,7 @@ public void drawMessageText(float textX, float textY, Canvas canvas, ArrayList maxWidth * .7f ? maxWidth : block.maxRight + AndroidUtilities.dp(24)); AndroidUtilities.rectTmp.set(0, -block.padTop + AndroidUtilities.dp(block.first ? 3 + 1.66f : 3), width, block.height + AndroidUtilities.dp(4)); @@ -12170,7 +12174,7 @@ public void drawMessageText(float textX, float textY, Canvas canvas, ArrayList 0) { SpannableStringBuilder builder = new SpannableStringBuilder(stickerSetName); try { builder.setSpan(new ForegroundColorSpan(getThemedColor(Theme.key_chat_emojiPanelStickerSetNameHighlight)), stickerSetNameSearchIndex, stickerSetNameSearchIndex + stickerSetNameSearchLength, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 786b24fa04..b9c8d39003 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -9702,7 +9702,7 @@ public void processInlineBotWebView(TLRPC.TL_inlineBotWebView object) { BotWebViewSheet webViewSheet = new BotWebViewSheet(getContext(), getResourceProvider()); webViewSheet.setParentActivity(getParentActivity()); webViewSheet.requestWebView(currentAccount, currentUser != null ? currentUser.id : currentChat.id, mentionContainer.getAdapter().getFoundContextBot().id, object.text, object.url, BotWebViewSheet.TYPE_SIMPLE_WEB_VIEW_BUTTON, 0, false, BotWebViewSheet.FLAG_FROM_INLINE_SWITCH); - showDialog(webViewSheet); + webViewSheet.show(); }; if (approved) { open.run(); @@ -11051,6 +11051,17 @@ public void searchLinks(final CharSequence charSequence, final boolean force) { if (currentEncryptedChat != null && getMessagesController().secretWebpagePreview == 0 || editingMessageObject != null && (!editingMessageObject.isWebpage() || editingMessageObject.messageOwner.media.webpage instanceof TLRPC.TL_webPagePending)) { return; } + if (currentChat != null && !ChatObject.canSendEmbed(currentChat)) { + if (foundWebPage != null) { + foundWebPage = null; + if (chatActivityEnterView != null) { + chatActivityEnterView.setWebPage(null, true); + } + fallbackFieldPanel(); + editResetMediaManual(); + } + return; + } checkEditLinkRemoved(charSequence); if (force && foundWebPage != null) { if (foundWebPage.url != null) { @@ -15024,7 +15035,7 @@ private void addToSelectedMessages(MessageObject messageObject, boolean outside) private void addToSelectedMessages(MessageObject messageObject, boolean outside, boolean last) { int prevCantForwardCount = cantForwardMessagesCount; if (messageObject != null) { - if (threadMessageObjects != null && threadMessageObjects.contains(messageObject)) { + if (threadMessageObjects != null && threadMessageObjects.contains(messageObject) && !isThreadChat()) { return; } int index = messageObject.getDialogId() == dialog_id ? 0 : 1; @@ -21669,14 +21680,14 @@ private void updateBottomOverlay() { if (currentChat.join_request) { shouldApply = true; if (requestedTime > 0 && System.currentTimeMillis() - requestedTime < 1000 * 60 * 2) { - bottomOverlayChatText.setText(LocaleController.getString("ChannelJoinRequestSent", R.string.ChannelJoinRequestSent), true); + bottomOverlayChatText.setText(LocaleController.getString(ChatObject.isChannelAndNotMegaGroup(currentChat) ? R.string.ChannelJoinRequestSent : R.string.GroupJoinRequestSent), true); bottomOverlayChatText.setEnabled(false); } else { - bottomOverlayChatText.setText(LocaleController.getString("ChannelJoinRequest", R.string.ChannelJoinRequest)); + bottomOverlayChatText.setText(LocaleController.getString(ChatObject.isChannelAndNotMegaGroup(currentChat) ? R.string.ChannelJoinRequest : R.string.GroupJoinRequest)); bottomOverlayChatText.setEnabled(true); } } else { - bottomOverlayChatText.setText(LocaleController.getString("ChannelJoin", R.string.ChannelJoin)); + bottomOverlayChatText.setText(LocaleController.getString(ChatObject.isChannelAndNotMegaGroup(currentChat) ? R.string.ChannelJoin : R.string.GroupJoin)); bottomOverlayChatText.setEnabled(true); } showBottomOverlayProgress(false, false); @@ -23921,7 +23932,7 @@ public void applyDraftMaybe(boolean canClear) { } if ((replyingMessageObject == null || threadMessageObject == replyingMessageObject) && draftReplyMessage != null && !(threadMessageObject != null && threadMessageObject.getId() == draftReplyMessage.id)) { replyingMessageObject = new MessageObject(currentAccount, draftReplyMessage, getMessagesController().getUsers(), false, false); - if (draftMessage.reply_to != null && (draftMessage.reply_to.flags & 64) != 0) { + if (draftMessage.reply_to != null && (draftMessage.reply_to.flags & 4) != 0) { replyingQuote = ReplyQuote.from(replyingMessageObject, draftMessage.reply_to.quote_text); } checkNewMessagesOnQuoteEdit(false); @@ -24336,7 +24347,7 @@ private boolean createMenu(View v, boolean single, boolean listView, float x, fl return true; } } - if (message.isSponsored() || threadMessageObjects != null && threadMessageObjects.contains(message)) { + if (message.isSponsored() || threadMessageObjects != null && threadMessageObjects.contains(message) && !isThreadChat()) { single = true; } @@ -26556,7 +26567,7 @@ private void processSelectedOption(int option) { Bundle args = new Bundle(); args.putBoolean("onlySelect", true); args.putInt("dialogsType", DialogsActivity.DIALOGS_TYPE_FORWARD); - args.putInt("messagesCount", forwardingMessageGroup == null ? 1 : forwardingMessageGroup.messages.size()); + args.putInt("messagesCount", 1); args.putInt("hasPoll", forwardingMessage.isPoll() ? (forwardingMessage.isPublicPoll() ? 2 : 1) : 0); args.putBoolean("hasInvoice", forwardingMessage.isInvoice()); args.putBoolean("canSelectTopics", true); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatEditActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatEditActivity.java index 46315afa77..e5fc3f5ef6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatEditActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatEditActivity.java @@ -139,6 +139,7 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image private TextCell adminCell; private TextCell blockCell; private TextCell logCell; + private TextCell statsAndBoosts; private TextCell setAvatarCell; private ShadowSectionCell infoSectionCell; @@ -1073,6 +1074,22 @@ public void afterTextChanged(Editable editable) { logCell.setOnClickListener(v -> presentFragment(new ChannelAdminLogActivity(currentChat))); } + if (ChatObject.isChannelAndNotMegaGroup(currentChat)) { + statsAndBoosts = new TextCell(context); + statsAndBoosts.setTextAndIcon(LocaleController.getString("StatisticsAndBoosts", R.string.StatisticsAndBoosts), R.drawable.msg_stats, true); + statsAndBoosts.setBackground(Theme.getSelectorDrawable(false)); + statsAndBoosts.setOnClickListener(v -> { + Bundle args = new Bundle(); + args.putLong("chat_id", chatId); + args.putBoolean("is_megagroup", currentChat.megagroup); + TLRPC.ChatFull chatInfo = getMessagesController().getChatFull(chatId); + if (chatInfo == null || !chatInfo.can_view_stats) { + args.putBoolean("only_boosts", true); + }; + presentFragment(new StatisticActivity(args)); + }); + } + infoContainer.addView(reactionsCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); if (!isChannel && !currentChat.gigagroup) { @@ -1107,8 +1124,13 @@ public void afterTextChanged(Editable editable) { groupStickersActivity.setInfo(info); presentFragment(groupStickersActivity); }); - } else if (logCell != null) { - infoContainer.addView(logCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); + } else { + if (statsAndBoosts != null) { + infoContainer.addView(statsAndBoosts, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); + } + if (logCell != null) { + infoContainer.addView(logCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); + } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java index 47ef81feb3..d18d44cb82 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java @@ -49,6 +49,7 @@ import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; +import android.view.ViewGroup; import android.view.ViewOutlineProvider; import android.view.WindowManager; import android.view.inputmethod.EditorInfo; @@ -119,6 +120,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -689,7 +691,7 @@ public static boolean checkSlowMode(Context context, int currentAccount, long di } } if (few) { - createSimpleAlert(context, chat.title, LocaleController.getString("SlowmodeSendError", R.string.SlowmodeSendError)).show(); + createSimpleAlert(context, chat.title, LocaleController.getString(R.string.SlowmodeSendError)).show(); return true; } } @@ -5659,7 +5661,8 @@ public static void createDeleteMessagesAlert(BaseFragment fragment, TLRPC.User u } final TLRPC.User userFinal = actionUser; final TLRPC.Chat chatFinal = actionChat; - builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialogInterface, i) -> { + + DialogInterface.OnClickListener deleteAction = (dialogInterface, i) -> { ArrayList ids = null; if (selectedMessage != null) { ids = new ArrayList<>(); @@ -5727,7 +5730,7 @@ public static void createDeleteMessagesAlert(BaseFragment fragment, TLRPC.User u if (onDelete != null) { onDelete.run(); } - }); + }; if (count == 1) { builder.setTitle(LocaleController.getString("DeleteSingleMessagesTitle", R.string.DeleteSingleMessagesTitle)); @@ -5765,6 +5768,34 @@ public static void createDeleteMessagesAlert(BaseFragment fragment, TLRPC.User u } } + boolean isGiveawayAndOwner = false; + String giveawayEndDate = null; + if (selectedMessage != null) { + isGiveawayAndOwner = selectedMessage.isGiveaway() && !selectedMessage.isForwarded(); + if (isGiveawayAndOwner) { + TLRPC.TL_messageMediaGiveaway giveaway = (TLRPC.TL_messageMediaGiveaway) selectedMessage.messageOwner.media; + giveawayEndDate = LocaleController.getInstance().formatterGiveawayMonthDayYear.format(new Date(giveaway.until_date * 1000L)); + } + } else if (count == 1) { + for (int a = 1; a >= 0; a--) { + for (int b = 0; b < selectedMessages[a].size(); b++) { + MessageObject msg = selectedMessages[a].valueAt(b); + isGiveawayAndOwner = msg.isGiveaway() && !msg.isForwarded(); + if (isGiveawayAndOwner) { + TLRPC.TL_messageMediaGiveaway giveaway = (TLRPC.TL_messageMediaGiveaway) msg.messageOwner.media; + giveawayEndDate = LocaleController.getInstance().formatterGiveawayMonthDayYear.format(new Date(giveaway.until_date * 1000L)); + } + } + } + } + + if (isGiveawayAndOwner) { + builder.setTitle(LocaleController.getString("BoostingGiveawayDeleteMsgTitle", R.string.BoostingGiveawayDeleteMsgTitle)); + builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("BoostingGiveawayDeleteMsgText", R.string.BoostingGiveawayDeleteMsgText, giveawayEndDate))); + builder.setNeutralButton(LocaleController.getString("Delete", R.string.Delete), deleteAction); + } else { + builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), deleteAction); + } builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); builder.setOnPreDismissListener(di -> { if (hideDim != null) { @@ -5773,9 +5804,15 @@ public static void createDeleteMessagesAlert(BaseFragment fragment, TLRPC.User u }); AlertDialog dialog = builder.create(); fragment.showDialog(dialog); - TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE); - if (button != null) { - button.setTextColor(Theme.getColor(Theme.key_text_RedBold)); + TextView positiveButton = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE); + if (positiveButton != null) { + positiveButton.setTextColor(Theme.getColor(Theme.key_text_RedBold)); + } + TextView neutralButton = (TextView) dialog.getButton(DialogInterface.BUTTON_NEUTRAL); + if (neutralButton != null) { + dialog.getButtonsLayout().setPadding(AndroidUtilities.dp(12), AndroidUtilities.dp(0), AndroidUtilities.dp(8), AndroidUtilities.dp(12)); + ((ViewGroup.MarginLayoutParams) dialog.getButtonsLayout().getLayoutParams()).topMargin = AndroidUtilities.dp(-8); + neutralButton.setTextColor(Theme.getColor(Theme.key_text_RedBold)); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarConstructorFragment.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarConstructorFragment.java index e02b8cffd8..9785586eb5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarConstructorFragment.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarConstructorFragment.java @@ -844,9 +844,7 @@ public ImageReceiver getImageReceiver() { ImageReceiver imageReceiver = backupImageView.getImageReceiver(); if (backupImageView.animatedEmojiDrawable != null) { imageReceiver = backupImageView.animatedEmojiDrawable.getImageReceiver(); - if (imageReceiver != null) { - imageReceiver.setColorFilter(colorFilter); - } + backupImageView.animatedEmojiDrawable.setColorFilter(colorFilter); } return imageReceiver; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/BotWebViewSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/BotWebViewSheet.java index 1f601fdcd5..71b51360d7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/BotWebViewSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/BotWebViewSheet.java @@ -16,6 +16,7 @@ import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; +import android.text.TextPaint; import android.text.TextUtils; import android.util.TypedValue; import android.view.Gravity; @@ -39,6 +40,7 @@ import org.telegram.messenger.AnimationNotificationsLocker; import org.telegram.messenger.ContactsController; import org.telegram.messenger.DialogObject; +import org.telegram.messenger.Emoji; import org.telegram.messenger.FileLog; import org.telegram.messenger.LocaleController; import org.telegram.messenger.MediaDataController; @@ -889,7 +891,13 @@ public void requestWebView(int currentAccount, long peerId, long botId, String b this.buttonText = buttonText; this.currentWebApp = app; - actionBar.setTitle(UserObject.getUserName(MessagesController.getInstance(currentAccount).getUser(botId))); + CharSequence title = UserObject.getUserName(MessagesController.getInstance(currentAccount).getUser(botId)); + try { + TextPaint tp = new TextPaint(); + tp.setTextSize(AndroidUtilities.dp(20)); + title = Emoji.replaceEmoji(title, tp.getFontMetricsInt(), false); + } catch (Exception ignore) {} + actionBar.setTitle(title); ActionBarMenu menu = actionBar.createMenu(); menu.removeAllViews(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/CaptionPhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/CaptionPhotoViewer.java index 94e70a055b..5c5bf8b02d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/CaptionPhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/CaptionPhotoViewer.java @@ -303,7 +303,7 @@ protected int additionalKeyboardHeight() { @Override public void updateColors(Theme.ResourcesProvider resourcesProvider) { super.updateColors(resourcesProvider); - timerDrawable.updateColors(0xffffffff, Theme.getColor(Theme.key_dialogFloatingButton, resourcesProvider)); + timerDrawable.updateColors(0xffffffff, Theme.getColor(Theme.key_chat_editMediaButton, resourcesProvider)); } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java index e61e17e51d..8632df7f25 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java @@ -3496,12 +3496,7 @@ private void openWebViewMenu() { BotWebViewSheet webViewSheet = new BotWebViewSheet(getContext(), parentFragment.getResourceProvider()); webViewSheet.setParentActivity(parentActivity); webViewSheet.requestWebView(currentAccount, dialog_id, dialog_id, botMenuWebViewTitle, botMenuWebViewUrl, BotWebViewSheet.TYPE_BOT_MENU_BUTTON, 0, false); - BaseFragment lastFragment = getLastFragment(); - if (lastFragment != null) { - lastFragment.showDialog(webViewSheet); - } else { - webViewSheet.show(); - } + webViewSheet.show(); if (botCommandsMenuButton != null) { botCommandsMenuButton.setOpened(false); @@ -3803,6 +3798,8 @@ private void createBotCommandsMenuContainer() { return; } botCommandsMenuContainer = new BotCommandsMenuContainer(getContext()) { + boolean ignoreLayout = false; + @Override protected void onDismiss() { super.onDismiss(); @@ -3810,6 +3807,15 @@ protected void onDismiss() { botCommandsMenuButton.setOpened(false); } } + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + super.onLayout(changed, left, top, right, bottom); + if (!ignoreLayout) { + ignoreLayout = true; + updateBotCommandsMenuContainerTopPadding(); + } + } }; botCommandsMenuContainer.listView.setLayoutManager(new LinearLayoutManager(getContext())); botCommandsMenuContainer.listView.setAdapter(botCommandsAdapter = new BotCommandsMenuView.BotCommandsAdapter()); @@ -3865,10 +3871,24 @@ private void updateBotCommandsMenuContainerTopPadding() { return; } int padding; - if (botCommandsAdapter.getItemCount() > 4) { - padding = Math.max(0, sizeNotifierLayout.getMeasuredHeight() - AndroidUtilities.dp(8 + 36 * 4.3f)); + + final int viewsCount = botCommandsMenuContainer.listView.getChildCount(); + int measuredFourViewsHeight = 0; + for (int i = 0; i < viewsCount; i++) { + final View child = botCommandsMenuContainer.listView.getChildAt(i); + if (i < 4) { + measuredFourViewsHeight += child.getMeasuredHeight(); + } + } + + if (measuredFourViewsHeight > 0) { + padding = Math.max(0, sizeNotifierLayout.getMeasuredHeight() - measuredFourViewsHeight - AndroidUtilities.dp(8) - AndroidUtilities.dp(viewsCount > 4 ? 12 : 0)); } else { - padding = Math.max(0, sizeNotifierLayout.getMeasuredHeight() - AndroidUtilities.dp(8 + 36 * Math.max(1, Math.min(4, botCommandsAdapter.getItemCount())))); + if (botCommandsAdapter.getItemCount() > 4) { + padding = Math.max(0, sizeNotifierLayout.getMeasuredHeight() - AndroidUtilities.dp(8 + 36 * 4.3f)); + } else { + padding = Math.max(0, sizeNotifierLayout.getMeasuredHeight() - AndroidUtilities.dp(8 + 36 * Math.max(1, Math.min(4, botCommandsAdapter.getItemCount())))); + } } if (botCommandsMenuContainer.listView.getPaddingTop() != padding) { @@ -5908,23 +5928,27 @@ public void doneEditingMessage() { editingMessageObject.editingMessage = message[0]; editingMessageObject.editingMessageEntities = entities; editingMessageObject.editingMessageSearchWebPage = messageWebPageSearch; - if (parentFragment != null && parentFragment.messagePreviewParams != null) { + if (parentFragment != null && parentFragment.getCurrentChat() != null && !ChatObject.canSendEmbed(parentFragment.getCurrentChat())) { + editingMessageObject.editingMessageSearchWebPage = false; + editingMessageObject.messageOwner.flags &=~ 512; + editingMessageObject.messageOwner.media = null; + } else if (parentFragment != null && parentFragment.messagePreviewParams != null) { if (parentFragment.foundWebPage instanceof TLRPC.TL_webPagePending) { editingMessageObject.editingMessageSearchWebPage = false; if (editingMessageObject.type == MessageObject.TYPE_TEXT || editingMessageObject.type == MessageObject.TYPE_EMOJIS) { editingMessageObject.messageOwner.media = new TLRPC.TL_messageMediaEmpty(); - editingMessageObject.messageOwner.media.flags |= 512; + editingMessageObject.messageOwner.flags |= 512; } } else if (parentFragment.messagePreviewParams.webpage != null) { editingMessageObject.editingMessageSearchWebPage = false; + editingMessageObject.messageOwner.flags |= 512; editingMessageObject.messageOwner.media = new TLRPC.TL_messageMediaWebPage(); - editingMessageObject.messageOwner.media.flags |= 512; editingMessageObject.messageOwner.media.webpage = parentFragment.messagePreviewParams.webpage; } else { editingMessageObject.editingMessageSearchWebPage = false; if (editingMessageObject.type == MessageObject.TYPE_TEXT || editingMessageObject.type == MessageObject.TYPE_EMOJIS) { + editingMessageObject.messageOwner.flags |= 512; editingMessageObject.messageOwner.media = new TLRPC.TL_messageMediaEmpty(); - editingMessageObject.messageOwner.media.flags |= 512; } } editingMessageObject.messageOwner.invert_media = parentFragment.messagePreviewParams.webpageTop; @@ -5935,8 +5959,8 @@ public void doneEditingMessage() { } else { editingMessageObject.editingMessageSearchWebPage = false; if (editingMessageObject.type == MessageObject.TYPE_TEXT || editingMessageObject.type == MessageObject.TYPE_EMOJIS) { + editingMessageObject.messageOwner.flags |= 512; editingMessageObject.messageOwner.media = new TLRPC.TL_messageMediaEmpty(); - editingMessageObject.messageOwner.media.flags |= 512; } } SendMessagesHelper.getInstance(currentAccount).editMessage(editingMessageObject, null, null, null, null, null, false, editingMessageObject.hasMediaSpoilers(), null); @@ -6030,7 +6054,10 @@ public boolean processSendingText(CharSequence text, boolean notify, int schedul SendMessagesHelper.SendMessageParams params = SendMessagesHelper.SendMessageParams.of(message[0].toString(), dialog_id, replyingMessageObject, replyToTopMsg, messageWebPage, messageWebPageSearch, entities, null, null, notify, scheduleDate, sendAnimationData, updateStickersOrder); applyStoryToSendMessageParams(params); params.invert_media = parentFragment != null && parentFragment.messagePreviewParams != null && parentFragment.messagePreviewParams.webpageTop; - if (messageWebPage instanceof TLRPC.TL_webPagePending) { + if (parentFragment != null && parentFragment.getCurrentChat() != null && !ChatObject.canSendEmbed(parentFragment.getCurrentChat())) { + params.searchLinks = false; + params.mediaWebPage = null; + } else if (messageWebPage instanceof TLRPC.TL_webPagePending) { params.searchLinks = true; params.mediaWebPage = null; } else if (messageWebPage != null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java index 2055dc7743..cdf325dac0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java @@ -2590,7 +2590,7 @@ public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { containerView.addView(writeButtonContainer, LayoutHelper.createFrame(60, 60, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, 6, 10)); writeButton = new ImageView(context); - writeButtonDrawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), getThemedColor(Theme.key_chat_attachCheckBoxBackground), getThemedColor(Build.VERSION.SDK_INT >= 21 ? Theme.key_dialogFloatingButtonPressed : Theme.key_chat_attachCheckBoxBackground)); + writeButtonDrawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), getThemedColor(Theme.key_dialogFloatingButton), getThemedColor(Build.VERSION.SDK_INT >= 21 ? Theme.key_dialogFloatingButtonPressed : Theme.key_dialogFloatingButton)); if (Build.VERSION.SDK_INT < 21) { Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow_profile).mutate(); shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY)); @@ -3713,8 +3713,8 @@ public void checkColors() { } } - Theme.setSelectorDrawableColor(writeButtonDrawable, getThemedColor(Theme.key_chat_attachCheckBoxBackground), false); - Theme.setSelectorDrawableColor(writeButtonDrawable, getThemedColor(Build.VERSION.SDK_INT >= 21 ? Theme.key_dialogFloatingButtonPressed : Theme.key_chat_attachCheckBoxBackground), true); + Theme.setSelectorDrawableColor(writeButtonDrawable, getThemedColor(Theme.key_dialogFloatingButton), false); + Theme.setSelectorDrawableColor(writeButtonDrawable, getThemedColor(Build.VERSION.SDK_INT >= 21 ? Theme.key_dialogFloatingButtonPressed : Theme.key_dialogFloatingButton), true); writeButton.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingIcon), PorterDuff.Mode.MULTIPLY)); actionBarShadow.setBackgroundColor(getThemedColor(Theme.key_dialogShadowLine)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertBotWebViewLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertBotWebViewLayout.java index a8b19c0079..c56d94fef8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertBotWebViewLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertBotWebViewLayout.java @@ -11,6 +11,7 @@ import android.graphics.Paint; import android.os.Build; import android.os.Bundle; +import android.text.TextPaint; import android.view.GestureDetector; import android.view.Gravity; import android.view.MotionEvent; @@ -32,6 +33,7 @@ import org.json.JSONObject; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.ContactsController; +import org.telegram.messenger.Emoji; import org.telegram.messenger.GenericProvider; import org.telegram.messenger.LocaleController; import org.telegram.messenger.MediaDataController; @@ -380,7 +382,13 @@ public void onPanTransitionEnd() { @Override void onShow(ChatAttachAlert.AttachAlertLayout previousLayout) { - parentAlert.actionBar.setTitle(UserObject.getUserName(MessagesController.getInstance(currentAccount).getUser(botId))); + CharSequence title = UserObject.getUserName(MessagesController.getInstance(currentAccount).getUser(botId)); + try { + TextPaint tp = new TextPaint(); + tp.setTextSize(AndroidUtilities.dp(20)); + title = Emoji.replaceEmoji(title, tp.getFontMetricsInt(), false); + } catch (Exception ignore) {} + parentAlert.actionBar.setTitle(title); swipeContainer.setSwipeOffsetY(0); if (webViewContainer.getWebView() != null) { webViewContainer.getWebView().scrollTo(0, 0); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertPhotoLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertPhotoLayout.java index f70bcc6fdb..6991a08bb3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertPhotoLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertPhotoLayout.java @@ -507,6 +507,11 @@ public void sendButtonPressed(int index, VideoEditedInfo videoEditedInfo, boolea selectedPhotosOrder.clear(); selectedPhotos.clear(); } + + @Override + public boolean allowCaption() { + return !parentAlert.isPhotoPicker; + } }; protected void updateCheckedPhotoIndices() { @@ -1897,6 +1902,11 @@ public boolean canScrollAway() { public boolean canCaptureMorePhotos() { return parentAlert.maxSelectedPhotos != 1; } + + @Override + public boolean allowCaption() { + return !parentAlert.isPhotoPicker; + } }, chatActivity); PhotoViewer.getInstance().setAvatarFor(parentAlert.getAvatarFor()); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Crop/CropRotationWheel.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Crop/CropRotationWheel.java index 12aa9780f6..972a51b307 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Crop/CropRotationWheel.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Crop/CropRotationWheel.java @@ -124,11 +124,11 @@ public void setFreeform(boolean freeform) { } public void setMirrored(boolean value) { - mirrorButton.setColorFilter(value ? new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogFloatingButton), PorterDuff.Mode.MULTIPLY) : null); + mirrorButton.setColorFilter(value ? new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_editMediaButton), PorterDuff.Mode.MULTIPLY) : null); } public void setRotated(boolean value) { - rotation90Button.setColorFilter(value ? new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogFloatingButton), PorterDuff.Mode.MULTIPLY) : null); + rotation90Button.setColorFilter(value ? new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_editMediaButton), PorterDuff.Mode.MULTIPLY) : null); } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/EditTextBoldCursor.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/EditTextBoldCursor.java index 242a487a68..7b0cfd2f6d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/EditTextBoldCursor.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/EditTextBoldCursor.java @@ -863,14 +863,10 @@ protected void onDraw(Canvas canvas) { throw new RuntimeException(e); } } - if (!EditTextEffects.allowHackingTextCanvas()) { - ignoreTopCount = 1; - ignoreBottomCount = 1; - } + ignoreTopCount = 1; + ignoreBottomCount = 1; canvas.save(); - if (!EditTextEffects.allowHackingTextCanvas()) { - canvas.translate(0, topPadding); - } + canvas.translate(0, topPadding); try { drawInMaim = true; super.onDraw(canvas); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/EditTextEffects.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/EditTextEffects.java index d8688f2d64..dd43d015ae 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/EditTextEffects.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/EditTextEffects.java @@ -276,8 +276,12 @@ public static boolean allowHackingTextCanvas() { if (allowHackingTextCanvasCache == null) { allowHackingTextCanvasCache = Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH && ( Build.MANUFACTURER == null || - !Build.MANUFACTURER.equalsIgnoreCase("HONOR") && - !Build.MANUFACTURER.equalsIgnoreCase("HUAWEI") + !Build.MANUFACTURER.toLowerCase().contains("honor") && + !Build.MANUFACTURER.toLowerCase().contains("huawei") && + !Build.MANUFACTURER.toLowerCase().contains("alps") + ) && ( + Build.MODEL == null || + !Build.MODEL.toLowerCase().contains("mediapad") ); } return allowHackingTextCanvasCache; @@ -290,19 +294,17 @@ public static boolean allowHackingTextCanvas() { protected void onDraw(Canvas canvas) { canvas.save(); if (clipToPadding && getScrollY() != 0) { - canvas.clipRect(-AndroidUtilities.dp(3), getScrollY() - getExtendedPaddingTop() - offsetY, getMeasuredWidth(), getMeasuredHeight() + getScrollY() + getExtendedPaddingBottom() - offsetY); + canvas.clipRect(-AndroidUtilities.dp(3), getScrollY() - super.getExtendedPaddingTop() - offsetY, getMeasuredWidth(), getMeasuredHeight() + getScrollY() + super.getExtendedPaddingBottom() - offsetY); } path.rewind(); for (SpoilerEffect eff : spoilers) { Rect bounds = eff.getBounds(); path.addRect(bounds.left, bounds.top, bounds.right, bounds.bottom, Path.Direction.CW); } - canvas.translate(0, getExtendedPaddingTop()); canvas.clipPath(path, Region.Op.DIFFERENCE); - canvas.translate(0, -getExtendedPaddingTop()); invalidateQuotes(false); for (int i = 0; i < quoteBlocks.size(); ++i) { - quoteBlocks.get(i).draw(canvas, getExtendedPaddingTop(), getWidth(), quoteColor, 1f); + quoteBlocks.get(i).draw(canvas, 0, getWidth(), quoteColor, 1f); } updateAnimatedEmoji(false); if (wrapCanvasToFixClipping) { @@ -316,21 +318,18 @@ protected void onDraw(Canvas canvas) { } if (drawAnimatedEmojiDrawables && animatedEmojiDrawables != null) { canvas.save(); - canvas.translate(getPaddingLeft(), getExtendedPaddingTop()); + canvas.translate(getPaddingLeft(), 0); AnimatedEmojiSpan.drawAnimatedEmojis(canvas, getLayout(), animatedEmojiDrawables, 0, spoilers, computeVerticalScrollOffset() - AndroidUtilities.dp(6), computeVerticalScrollOffset() + computeVerticalScrollExtent(), 0, 1f, animatedEmojiColorFilter); canvas.restore(); } canvas.restore(); canvas.save(); - canvas.translate(0, getExtendedPaddingTop()); canvas.clipPath(path); path.rewind(); - canvas.translate(0, -getExtendedPaddingTop()); if (!spoilers.isEmpty()) spoilers.get(0).getRipplePath(path); canvas.clipPath(path); - canvas.translate(0, getExtendedPaddingTop()); canvas.translate(0, -getPaddingTop()); if (wrapCanvasToFixClipping) { if (wrappedCanvas == null) { @@ -343,9 +342,8 @@ protected void onDraw(Canvas canvas) { } canvas.restore(); - rect.set(0, (int) (getScrollY() - getExtendedPaddingTop() - offsetY), getWidth(), (int) (getMeasuredHeight() + getScrollY() + getExtendedPaddingBottom() - offsetY)); + rect.set(0, (int) (getScrollY() - super.getExtendedPaddingTop() - offsetY), getWidth(), (int) (getMeasuredHeight() + getScrollY() + super.getExtendedPaddingBottom() - offsetY)); canvas.save(); - canvas.translate(0, getExtendedPaddingTop()); canvas.clipRect(rect); for (SpoilerEffect eff : spoilers) { Rect b = eff.getBounds(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiTabsStrip.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiTabsStrip.java index 4bbbd0c972..a0b99a14c7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiTabsStrip.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiTabsStrip.java @@ -485,7 +485,7 @@ public void updateEmojiPacks(ArrayList emojiPacks) { } else { currentPackButton.setDrawable(getResources().getDrawable(newPack.resId).mutate()); currentPackButton.updateColor(); - currentPackButton.setLock(null); + currentPackButton.setLock(null, false); } } else { final boolean free = newPack.free; @@ -499,13 +499,13 @@ public void updateEmojiPacks(ArrayList emojiPacks) { } currentPackButton.updateSelect(selected == i, false); if (currentType == SelectAnimatedEmojiDialog.TYPE_AVATAR_CONSTRUCTOR || currentType == SelectAnimatedEmojiDialog.TYPE_SET_REPLY_ICON) { - currentPackButton.setLock(null); + currentPackButton.setLock(null, false); } else if (!isPremium && !free) { - currentPackButton.setLock(true); + currentPackButton.setLock(true, false); } else if (!this.isInstalled(newPack)) { - currentPackButton.setLock(false); + currentPackButton.setLock(false, false); } else { - currentPackButton.setLock(null); + currentPackButton.setLock(null, false); } if (doAppearAnimation && !first) { currentPackButton.newly = false; @@ -936,14 +936,14 @@ private void initLock() { } } - public void setLock(Boolean lock) { + public void setLock(Boolean lock, boolean animated) { if (lockView == null) { return; } if (lock == null) { - updateLock(false); + updateLock(false, animated); } else { - updateLock(true); + updateLock(true, animated); if (lock) { lockView.setImageResource(R.drawable.msg_mini_lockedemoji); } else { @@ -957,32 +957,40 @@ public void setLock(Boolean lock) { private float lockT; private ValueAnimator lockAnimator; - private void updateLock(boolean enable) { + private void updateLock(boolean enable, boolean animated) { if (lockAnimator != null) { lockAnimator.cancel(); } if (Math.abs(lockT - (enable ? 1f : 0f)) < 0.01f) { return; } - lockView.setVisibility(View.VISIBLE); - lockAnimator = ValueAnimator.ofFloat(lockT, enable ? 1f : 0f); - lockAnimator.addUpdateListener(anm -> { - lockT = (float) anm.getAnimatedValue(); + if (animated) { + lockView.setVisibility(View.VISIBLE); + lockAnimator = ValueAnimator.ofFloat(lockT, enable ? 1f : 0f); + lockAnimator.addUpdateListener(anm -> { + lockT = (float) anm.getAnimatedValue(); + lockView.setScaleX(lockT); + lockView.setScaleY(lockT); + lockView.setAlpha(lockT); + }); + lockAnimator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + if (!enable) { + lockView.setVisibility(View.GONE); + } + } + }); + lockAnimator.setInterpolator(CubicBezierInterpolator.DEFAULT); + lockAnimator.setDuration(HwEmojis.isHwEnabledOrPreparing() ? 0 : 200); + lockAnimator.start(); + } else { + lockT = enable ? 1f : 0f; lockView.setScaleX(lockT); lockView.setScaleY(lockT); lockView.setAlpha(lockT); - }); - lockAnimator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - if (!enable) { - lockView.setVisibility(View.GONE); - } - } - }); - lockAnimator.setInterpolator(CubicBezierInterpolator.DEFAULT); - lockAnimator.setDuration(HwEmojis.isHwEnabledOrPreparing() ? 0 : 200); - lockAnimator.start(); + lockView.setVisibility(enable ? View.VISIBLE : View.GONE); + } } public void updateLockImageReceiver() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java index 31692cdcfb..f82d065c44 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java @@ -9,6 +9,7 @@ package org.telegram.ui.Components; import static org.telegram.messenger.AndroidUtilities.dp; +import static org.telegram.messenger.AndroidUtilities.translitSafe; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -135,6 +136,7 @@ import org.telegram.ui.Components.Premium.PremiumButtonView; import org.telegram.ui.Components.Premium.PremiumGradient; import org.telegram.ui.ContentPreviewViewer; +import org.telegram.ui.SelectAnimatedEmojiDialog; import org.telegram.ui.StickersActivity; import java.lang.annotation.Retention; @@ -144,8 +146,10 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Objects; @@ -1649,9 +1653,11 @@ public void onEnd() { @Override public int getSpanSize(int position) { if (emojiGridView.getAdapter() == emojiSearchAdapter) { + final int viewType = emojiSearchAdapter.getItemViewType(position); if ( - position == 0 || - position == 1 && emojiSearchAdapter.searchWas && emojiSearchAdapter.result.isEmpty() + viewType == EmojiSearchAdapter.VIEW_TYPE_SEARCHFIELD || + viewType == EmojiSearchAdapter.VIEW_TYPE_HEADER || + viewType == EmojiSearchAdapter.VIEW_TYPE_HELP ) { return emojiLayoutManager.getSpanCount(); } @@ -7302,19 +7308,25 @@ public ArrayList getEmojipacks() { private class EmojiSearchAdapter extends RecyclerListView.SelectionAdapter { - private ArrayList result = new ArrayList<>(); + private final ArrayList result = new ArrayList<>(); + private final ArrayList packs = new ArrayList<>(); private String lastSearchEmojiString; private String lastSearchAlias; private Runnable searchRunnable; private boolean searchWas; + private static final int VIEW_TYPE_EMOJI = 0; + private static final int VIEW_TYPE_SEARCHFIELD = 1; + private static final int VIEW_TYPE_HELP = 2; + private static final int VIEW_TYPE_HEADER = 3; + @Override public int getItemCount() { - if (result.isEmpty() && !searchWas) { + if (result.isEmpty() && packs.isEmpty() && !searchWas) { return getRecentEmoji().size() + 1; } - if (!result.isEmpty()) { - return result.size() + 1; + if (!result.isEmpty() || !packs.isEmpty()) { + return result.size() + packs.size() + 1; } return 2; } @@ -7328,14 +7340,17 @@ public boolean isEnabled(RecyclerView.ViewHolder holder) { public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view; switch (viewType) { - case 0: + case VIEW_TYPE_EMOJI: view = new ImageViewEmoji(getContext()); break; - case 1: + case VIEW_TYPE_SEARCHFIELD: view = new View(getContext()); view.setLayoutParams(new RecyclerView.LayoutParams(LayoutHelper.MATCH_PARENT, searchFieldHeight)); break; - case 2: + case VIEW_TYPE_HEADER: + view = new StickerSetNameCell(getContext(), true, resourcesProvider); + break; + case VIEW_TYPE_HELP: default: FrameLayout frameLayout = new FrameLayout(getContext()) { @Override @@ -7450,22 +7465,30 @@ public void onClick(View v) { @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { switch (holder.getItemViewType()) { - case 0: { + case VIEW_TYPE_EMOJI: { ImageViewEmoji imageView = (ImageViewEmoji) holder.itemView; imageView.position = position; imageView.pack = null; - String code; - String coloredCode; + String code = null; + String coloredCode = null; boolean recent; position--; Long customEmojiId = null; + TLRPC.Document document = null; if (result.isEmpty() && !searchWas) { coloredCode = code = getRecentEmoji().get(position); recent = true; } else { - coloredCode = code = result.get(position).emoji; + if (position >= 0 && position < result.size()) { + coloredCode = code = result.get(position).emoji; + } else { + position -= result.size(); + if (position >= 0 && position < packs.size()) { + document = packs.get(position); + } + } recent = false; } @@ -7477,34 +7500,66 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { } catch (Exception ignore) {} } - if (customEmojiId != null) { + if (document != null || customEmojiId != null) { imageView.setPadding(AndroidUtilities.dp(3), AndroidUtilities.dp(3), AndroidUtilities.dp(3), AndroidUtilities.dp(3)); } else { imageView.setPadding(0, 0, 0, 0); } - if (customEmojiId != null) { + if (document != null) { + imageView.setImageDrawable(null, recent); + if (imageView.getSpan() == null || imageView.getSpan().document != document) { + imageView.setSpan(new AnimatedEmojiSpan(document, null)); + } + } else if (customEmojiId != null) { imageView.setImageDrawable(null, recent); if (imageView.getSpan() == null || imageView.getSpan().getDocumentId() != customEmojiId) { imageView.setSpan(new AnimatedEmojiSpan(customEmojiId, null)); } - } else { + } else if (coloredCode != null) { imageView.setImageDrawable(Emoji.getEmojiBigDrawable(coloredCode), recent); imageView.setSpan(null); + } else { + imageView.setImageDrawable(null, recent); + imageView.setSpan(null); } imageView.setTag(code); break; } + case VIEW_TYPE_HEADER: { + position--; + position -= result.size(); + if (position >= 0 && position < packs.size()) { + TLRPC.Document document = packs.get(position); + if (document instanceof SelectAnimatedEmojiDialog.SetTitleDocument) { + StickerSetNameCell cell = (StickerSetNameCell) holder.itemView; + final String title = ((SelectAnimatedEmojiDialog.SetTitleDocument) document).title; + final int index = lastSearchEmojiString == null || title == null ? -1 : title.toLowerCase().indexOf(lastSearchEmojiString.toLowerCase()); + if (index >= 0) { + cell.setText(title, 0, index, lastSearchEmojiString.length()); + } else { + cell.setText(title, 0); + } + } + } + break; + } } } @Override public int getItemViewType(int position) { if (position == 0) { - return 1; + return VIEW_TYPE_SEARCHFIELD; } else if (position == 1 && searchWas && result.isEmpty()) { - return 2; + return VIEW_TYPE_HELP; } - return 0; + if (!packs.isEmpty()) { + position -= 1 + result.size(); + if (position >= 0 && position < packs.size() && packs.get(position) instanceof SelectAnimatedEmojiDialog.SetTitleDocument) { + return VIEW_TYPE_HEADER; + } + } + return VIEW_TYPE_EMOJI; } public void search(String text) { @@ -7536,34 +7591,87 @@ public void search(String text, boolean delay) { MediaDataController.getInstance(currentAccount).fetchNewEmojiKeywords(newLanguage); } lastSearchKeyboardLanguage = newLanguage; - MediaDataController.getInstance(currentAccount).getEmojiSuggestions(lastSearchKeyboardLanguage, lastSearchEmojiString, false, new MediaDataController.KeywordResultCallback() { - @Override - public void run(ArrayList param, String alias) { - if (query.equals(lastSearchEmojiString)) { - lastSearchAlias = alias; - emojiSearchField.showProgress(false); - searchWas = true; - if (emojiGridView.getAdapter() != emojiSearchAdapter) { - emojiGridView.setAdapter(emojiSearchAdapter); + final ArrayList searchResult = new ArrayList<>(); + final ArrayList packsResult = new ArrayList<>(); + Utilities.doCallbacks( + next -> { + MediaDataController.getInstance(currentAccount).getEmojiSuggestions(lastSearchKeyboardLanguage, lastSearchEmojiString, false, (param, alias) -> { + if (!query.equals(lastSearchEmojiString)) { + return; } - result.clear(); - searchByPackname(query, documentIds); - for (long documentId : documentIds) { - MediaDataController.KeywordResult r = new MediaDataController.KeywordResult(); - r.keyword = ""; - r.emoji = "animated_" + documentId; - result.add(r); + lastSearchAlias = alias; + searchResult.addAll(param); + + next.run(); + }, null, SharedConfig.suggestAnimatedEmoji || UserConfig.getInstance(currentAccount).isPremium(), false, true, 25); + }, + next -> { + if (SharedConfig.suggestAnimatedEmoji || UserConfig.getInstance(currentAccount).isPremium()) { + final String q = translitSafe((query + "").toLowerCase()); + final ArrayList sets = MediaDataController.getInstance(currentAccount).getStickerSets(MediaDataController.TYPE_EMOJIPACKS); + + final HashSet addedSets = new HashSet<>(); + if (sets != null) { + for (int i = 0; i < sets.size(); ++i) { + TLRPC.TL_messages_stickerSet set = sets.get(i); + if (set == null || set.set == null || set.set.title == null || set.documents == null || set.documents.isEmpty() || addedSets.contains(set.set.id)) { + continue; + } + final String title = translitSafe(set.set.title.toLowerCase()); + if (title.startsWith(q) || title.contains(" " + q)) { + packsResult.add(new SelectAnimatedEmojiDialog.SetTitleDocument(set.set.title)); + packsResult.addAll(set.documents); + addedSets.add(set.set.id); + } + } } - for (int i = 0; i < param.size(); ++i) { - MediaDataController.KeywordResult r = param.get(i); - if (r != null && r.emoji != null && (!r.emoji.startsWith("animated_") || !documentIds.contains(Long.parseLong(r.emoji.substring(9))))) { - result.add(r); + + final ArrayList favs = MediaDataController.getInstance(currentAccount).getFeaturedEmojiSets(); + if (favs != null) { + for (int i = 0; i < favs.size(); ++i) { + TLRPC.StickerSetCovered fav = favs.get(i); + if (fav == null || fav.set == null || fav.set.title == null || addedSets.contains(fav.set.id)) continue; + final String title = translitSafe(fav.set.title.toLowerCase()); + if (title.startsWith(q) || title.contains(" " + q)) { + ArrayList documents = null; + if (fav instanceof TLRPC.TL_stickerSetFullCovered) { + documents = ((TLRPC.TL_stickerSetFullCovered) fav).documents; + } else if (fav instanceof TLRPC.TL_stickerSetNoCovered) { + TLRPC.TL_messages_stickerSet set = MediaDataController.getInstance(currentAccount).getStickerSet(MediaDataController.getInputStickerSet(fav.set), fav.set.hash, true); + if (set != null) { + documents = set.documents; + } + } else { + documents = fav.covers; + } + if (documents != null && !documents.isEmpty()) { + packsResult.add(new SelectAnimatedEmojiDialog.SetTitleDocument(fav.set.title)); + packsResult.addAll(documents); + addedSets.add(fav.set.id); + } + } } } - notifyDataSetChanged(); } + next.run(); + }, + next -> { + if (!query.equals(lastSearchEmojiString)) { + return; + } + emojiSearchField.showProgress(false); + searchWas = true; + if (emojiGridView.getAdapter() != emojiSearchAdapter) { + emojiGridView.setAdapter(emojiSearchAdapter); + } + result.clear(); + result.addAll(searchResult); + packs.clear(); + packs.addAll(packsResult); + notifyDataSetChanged(); } - }, null, SharedConfig.suggestAnimatedEmoji, false, true, 25); + ); + }; if (Emoji.fullyConsistsOfEmojis(query)) { StickerCategoriesListView.search.fetch(UserConfig.selectedAccount, query, list -> { @@ -7578,57 +7686,6 @@ public void run(ArrayList param, String alias }, delay ? 300 : 0); } } - - private ArrayList addedSets = new ArrayList<>(); - - private void searchByPackname(String query, LinkedHashSet documentIds) { - if (query == null || query.length() <= 3 || !UserConfig.getInstance(currentAccount).isPremium()) { - return; - } - String translitQuery = LocaleController.getInstance().getTranslitString(query).toLowerCase(); - - ArrayList sets = MediaDataController.getInstance(currentAccount).getStickerSets(MediaDataController.TYPE_EMOJIPACKS); - ArrayList featuredSets = MediaDataController.getInstance(currentAccount).getFeaturedEmojiSets(); - addedSets.clear(); - - for (int i = 0; i < sets.size(); ++i) { - TLRPC.TL_messages_stickerSet fullSet = sets.get(i); - if (fullSet == null || fullSet.set == null) { - continue; - } - checkAddPackToResults(fullSet.set, fullSet.documents, translitQuery, documentIds); - } - for (int i = 0; i < featuredSets.size(); ++i) { - TLRPC.StickerSetCovered coveredSet = featuredSets.get(i); - if (coveredSet == null || coveredSet.set == null) { - continue; - } - if (coveredSet instanceof TLRPC.TL_stickerSetFullCovered) { - checkAddPackToResults(coveredSet.set, ((TLRPC.TL_stickerSetFullCovered) coveredSet).documents, translitQuery, documentIds); - } else if (coveredSet instanceof TLRPC.TL_stickerSetNoCovered) { - TLRPC.TL_inputStickerSetID inputStickerSetID = new TLRPC.TL_inputStickerSetID(); - inputStickerSetID.id = coveredSet.set.id; - TLRPC.TL_messages_stickerSet fullSet = MediaDataController.getInstance(currentAccount).getStickerSet(inputStickerSetID, true); - if (fullSet != null) { - checkAddPackToResults(fullSet.set, fullSet.documents, translitQuery, documentIds); - } - } else { - checkAddPackToResults(coveredSet.set, coveredSet.covers, translitQuery, documentIds); - } - } - } - - private void checkAddPackToResults(TLRPC.StickerSet set, ArrayList documents, String translitQuery, LinkedHashSet documentIds) { - if (set.title != null && !addedSets.contains(set.id) && LocaleController.getInstance().getTranslitString(set.title.toLowerCase()).contains(translitQuery)) { - for (TLRPC.Document document : documents) { - if (document == null) { - continue; - } - documentIds.add(document.id); - } - addedSets.add(set.id); - } - } } private class EmojiPagesAdapter extends PagerAdapter implements PagerSlidingTabStrip.IconTabProvider { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoCropView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoCropView.java index 2b78dbeb31..39851949a6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoCropView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoCropView.java @@ -226,7 +226,7 @@ protected boolean drawChild(Canvas canvas, View child, long drawingTime) { canvas.drawCircle(rect.centerX(), rect.centerY(), rect.width() / 2, circlePaint); } - circlePaint.setColor(getThemedColor(Theme.key_dialogFloatingButton)); + circlePaint.setColor(getThemedColor(Theme.key_chat_editMediaButton)); circlePaint.setAlpha(Math.min(255, (int) (255 * thumbAnimationProgress * thumbImageVisibleProgress))); canvas.drawCircle(targetX + targetSize / 2, targetY + targetSize + AndroidUtilities.dp(8), AndroidUtilities.dp(3), circlePaint); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterView.java index df2e23f752..789ccee99f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterView.java @@ -497,7 +497,7 @@ public void onSurfaceTextureUpdated(SurfaceTexture surface) { doneTextView = new TextView(context); doneTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); - doneTextView.setTextColor(getThemedColor(Theme.key_dialogFloatingButton)); + doneTextView.setTextColor(getThemedColor(Theme.key_chat_editMediaButton)); doneTextView.setGravity(Gravity.CENTER); doneTextView.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR, 0)); doneTextView.setPadding(AndroidUtilities.dp(20), 0, AndroidUtilities.dp(20), 0); @@ -511,12 +511,12 @@ public void onSurfaceTextureUpdated(SurfaceTexture surface) { tuneItem = new ImageView(context); tuneItem.setScaleType(ImageView.ScaleType.CENTER); tuneItem.setImageResource(R.drawable.msg_photo_settings); - tuneItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingButton), PorterDuff.Mode.MULTIPLY)); + tuneItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_editMediaButton), PorterDuff.Mode.MULTIPLY)); tuneItem.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.ACTION_BAR_WHITE_SELECTOR_COLOR)); linearLayout.addView(tuneItem, LayoutHelper.createLinear(56, 48)); tuneItem.setOnClickListener(v -> { selectedTool = 0; - tuneItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingButton), PorterDuff.Mode.MULTIPLY)); + tuneItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_editMediaButton), PorterDuff.Mode.MULTIPLY)); blurItem.setColorFilter(null); curveItem.setColorFilter(null); switchMode(); @@ -530,7 +530,7 @@ public void onSurfaceTextureUpdated(SurfaceTexture surface) { blurItem.setOnClickListener(v -> { selectedTool = 1; tuneItem.setColorFilter(null); - blurItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingButton), PorterDuff.Mode.MULTIPLY)); + blurItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_editMediaButton), PorterDuff.Mode.MULTIPLY)); curveItem.setColorFilter(null); switchMode(); }); @@ -547,7 +547,7 @@ public void onSurfaceTextureUpdated(SurfaceTexture surface) { selectedTool = 2; tuneItem.setColorFilter(null); blurItem.setColorFilter(null); - curveItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingButton), PorterDuff.Mode.MULTIPLY)); + curveItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_editMediaButton), PorterDuff.Mode.MULTIPLY)); switchMode(); }); @@ -676,16 +676,16 @@ public void onSurfaceTextureUpdated(SurfaceTexture surface) { public void updateColors() { if (doneTextView != null) { - doneTextView.setTextColor(getThemedColor(Theme.key_dialogFloatingButton)); + doneTextView.setTextColor(getThemedColor(Theme.key_chat_editMediaButton)); } if (tuneItem != null && tuneItem.getColorFilter() != null) { - tuneItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingButton), PorterDuff.Mode.MULTIPLY)); + tuneItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_editMediaButton), PorterDuff.Mode.MULTIPLY)); } if (blurItem != null && blurItem.getColorFilter() != null) { - blurItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingButton), PorterDuff.Mode.MULTIPLY)); + blurItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_editMediaButton), PorterDuff.Mode.MULTIPLY)); } if (curveItem != null && curveItem.getColorFilter() != null) { - curveItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingButton), PorterDuff.Mode.MULTIPLY)); + curveItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_editMediaButton), PorterDuff.Mode.MULTIPLY)); } updateSelectedBlurType(); } @@ -693,9 +693,9 @@ public void updateColors() { private void updateSelectedBlurType() { if (blurType == 0) { Drawable drawable = blurOffButton.getContext().getResources().getDrawable(R.drawable.msg_blur_off).mutate(); - drawable.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingButton), PorterDuff.Mode.MULTIPLY)); + drawable.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_editMediaButton), PorterDuff.Mode.MULTIPLY)); blurOffButton.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null); - blurOffButton.setTextColor(getThemedColor(Theme.key_dialogFloatingButton)); + blurOffButton.setTextColor(getThemedColor(Theme.key_chat_editMediaButton)); blurRadialButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.msg_blur_radial, 0, 0); blurRadialButton.setTextColor(0xffffffff); @@ -707,9 +707,9 @@ private void updateSelectedBlurType() { blurOffButton.setTextColor(0xffffffff); Drawable drawable = blurOffButton.getContext().getResources().getDrawable(R.drawable.msg_blur_radial).mutate(); - drawable.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingButton), PorterDuff.Mode.MULTIPLY)); + drawable.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_editMediaButton), PorterDuff.Mode.MULTIPLY)); blurRadialButton.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null); - blurRadialButton.setTextColor(getThemedColor(Theme.key_dialogFloatingButton)); + blurRadialButton.setTextColor(getThemedColor(Theme.key_chat_editMediaButton)); blurLinearButton.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.msg_blur_linear, 0, 0); blurLinearButton.setTextColor(0xffffffff); @@ -721,9 +721,9 @@ private void updateSelectedBlurType() { blurRadialButton.setTextColor(0xffffffff); Drawable drawable = blurOffButton.getContext().getResources().getDrawable(R.drawable.msg_blur_linear).mutate(); - drawable.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingButton), PorterDuff.Mode.MULTIPLY)); + drawable.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_editMediaButton), PorterDuff.Mode.MULTIPLY)); blurLinearButton.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null); - blurLinearButton.setTextColor(getThemedColor(Theme.key_dialogFloatingButton)); + blurLinearButton.setTextColor(getThemedColor(Theme.key_chat_editMediaButton)); } updateFiltersEmpty(); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoViewerCaptionEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoViewerCaptionEnterView.java index 622359224e..2a8bf63c77 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoViewerCaptionEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoViewerCaptionEnterView.java @@ -495,7 +495,7 @@ public void setForceFloatingEmoji(boolean value) { } public void updateColors() { - Theme.setDrawableColor(doneDrawable, getThemedColor(Theme.key_dialogFloatingButton)); + Theme.setDrawableColor(doneDrawable, getThemedColor(Theme.key_chat_editMediaButton)); int color = getThemedColor(Theme.key_dialogFloatingIcon); int alpha = Color.alpha(color); Theme.setDrawableColor(checkDrawable, ColorUtils.setAlphaComponent(color, (int) (alpha * (0.58f + 0.42f * sendButtonEnabledProgress)))); @@ -619,7 +619,7 @@ public int getColor(int key) { return 771751936; } else if (key == Theme.key_divider) { return -16777216; - } else if (key == Theme.key_dialogFloatingButton) { + } else if (key == Theme.key_chat_editMediaButton) { return -10177041; } else if (key == Theme.key_dialogFloatingIcon) { return 0xffffffff; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/LimitReachedBottomSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/LimitReachedBottomSheet.java index 3c6b797b75..b1c1aa414e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/LimitReachedBottomSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/LimitReachedBottomSheet.java @@ -1057,7 +1057,7 @@ public HeaderView(Context context) { } else { descriptionStr = LocaleController.formatString( "ChannelNeedBoostsDescriptionNextLevel", R.string.ChannelNeedBoostsDescriptionNextLevel, - LocaleController.formatPluralString("MoreBoosts", boostsStatus.next_level_boosts, boostsStatus.next_level_boosts), + LocaleController.formatPluralString("MoreBoosts", boostsStatus.next_level_boosts - boostsStatus.boosts, boostsStatus.next_level_boosts - boostsStatus.boosts), LocaleController.formatPluralString("BoostStories", boostsStatus.level + 1) ); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/BoostDialogs.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/BoostDialogs.java index d08db75a14..64ea478d74 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/BoostDialogs.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/BoostDialogs.java @@ -615,13 +615,14 @@ public static void showAboutEnd(String from, long msgDate, TLRPC.TL_payments_giv builder.show(); } - public static void showPrivateChannelAlert(Context context, Theme.ResourcesProvider resourcesProvider, Runnable onCanceled) { + public static void showPrivateChannelAlert(Context context, Theme.ResourcesProvider resourcesProvider, Runnable onCanceled, Runnable onAccepted) { final AtomicBoolean isAddButtonClicked = new AtomicBoolean(false); AlertDialog.Builder builder = new AlertDialog.Builder(context, resourcesProvider); builder.setTitle(getString("BoostingGiveawayPrivateChannel", R.string.BoostingGiveawayPrivateChannel)); builder.setMessage(getString("BoostingGiveawayPrivateChannelWarning", R.string.BoostingGiveawayPrivateChannelWarning)); builder.setPositiveButton(getString("Add", R.string.Add), (dialogInterface, i) -> { isAddButtonClicked.set(true); + onAccepted.run(); }); builder.setNegativeButton(getString("Cancel", R.string.Cancel), (dialogInterface, i) -> { @@ -763,4 +764,21 @@ public static void showFloodWait(int time) { }); builder.show(); } + + public static void showStartGiveawayDialog(Runnable onStart) { + BaseFragment baseFragment = LaunchActivity.getLastFragment(); + if (baseFragment == null) { + return; + } + AlertDialog.Builder builder = new AlertDialog.Builder(baseFragment.getContext(), baseFragment.getResourceProvider()); + builder.setTitle(LocaleController.getString("BoostingStartGiveawayConfirmTitle", R.string.BoostingStartGiveawayConfirmTitle)); + builder.setMessage(AndroidUtilities.replaceTags(LocaleController.getString("BoostingStartGiveawayConfirmText", R.string.BoostingStartGiveawayConfirmText))); + builder.setPositiveButton(LocaleController.getString("Start", R.string.Start), (dialog, which) -> { + onStart.run(); + }); + builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), (dialog, which) -> { + dialog.dismiss(); + }); + builder.show(); + } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/BoostPagerBottomSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/BoostPagerBottomSheet.java index 2977b64338..b131e0a80b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/BoostPagerBottomSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/BoostPagerBottomSheet.java @@ -209,9 +209,9 @@ public void onSelectCountries(List countries) { }); rightSheet.setSelectedObjectsListener(new SelectorBottomSheet.SelectedObjectsListener() { @Override - public void onChatsSelected(List chats) { + public void onChatsSelected(List chats, boolean animated) { viewPager.scrollToPosition(0); - leftSheet.onChatsSelected(chats); + leftSheet.onChatsSelected(chats, !isKeyboardVisible()); } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/BoostViaGiftsBottomSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/BoostViaGiftsBottomSheet.java index b4ad98c102..9f89f3fa23 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/BoostViaGiftsBottomSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/BoostViaGiftsBottomSheet.java @@ -171,17 +171,19 @@ public BoostViaGiftsBottomSheet(BaseFragment fragment, boolean needFocus, boolea } else { List options = BoostRepository.filterGiftOptions(giftCodeOptions, getSelectedSliderValue()); if (isPreparedGiveaway()) { - int dateInt = BoostRepository.prepareServerDate(selectedEndDate); - boolean onlyNewSubscribers = selectedParticipantsType == ParticipantsTypeCell.TYPE_NEW; - actionBtn.updateLoading(true); - BoostRepository.launchPreparedGiveaway(prepaidGiveaway, selectedChats, selectedCountries, currentChat, dateInt, onlyNewSubscribers, - result -> { - dismiss(); - AndroidUtilities.runOnUIThread(() -> NotificationCenter.getInstance(UserConfig.selectedAccount).postNotificationName(NotificationCenter.boostByChannelCreated, currentChat, true, prepaidGiveaway), 220); - }, error -> { - actionBtn.updateLoading(false); - BoostDialogs.showToastError(getContext(), error); - }); + BoostDialogs.showStartGiveawayDialog(() -> { + int dateInt = BoostRepository.prepareServerDate(selectedEndDate); + boolean onlyNewSubscribers = selectedParticipantsType == ParticipantsTypeCell.TYPE_NEW; + actionBtn.updateLoading(true); + BoostRepository.launchPreparedGiveaway(prepaidGiveaway, selectedChats, selectedCountries, currentChat, dateInt, onlyNewSubscribers, + result -> { + dismiss(); + AndroidUtilities.runOnUIThread(() -> NotificationCenter.getInstance(UserConfig.selectedAccount).postNotificationName(NotificationCenter.boostByChannelCreated, currentChat, true, prepaidGiveaway), 220); + }, error -> { + actionBtn.updateLoading(false); + BoostDialogs.showToastError(getContext(), error); + }); + }); } else { for (int i = 0; i < options.size(); i++) { TLRPC.TL_premiumGiftCodeOption option = options.get(i); @@ -371,10 +373,10 @@ protected RecyclerListView.SelectionAdapter createAdapter() { } @Override - public void onChatsSelected(List chats) { + public void onChatsSelected(List chats, boolean animated) { selectedChats.clear(); selectedChats.addAll(chats); - updateRows(true, true); + updateRows(animated, true); } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/ReassignBoostBottomSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/ReassignBoostBottomSheet.java index 991cc28ced..5f86010612 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/ReassignBoostBottomSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/ReassignBoostBottomSheet.java @@ -332,10 +332,12 @@ private static class TopCell extends LinearLayout { public TopCell(Context context) { super(context); setOrientation(LinearLayout.VERTICAL); - + setClipChildren(false); avatarsContainer = new FrameLayout(getContext()); - + avatarsContainer.setClipChildren(false); avatarsWrapper = new FrameLayout(getContext()); + avatarsWrapper.setClipChildren(false); + avatarsContainer.addView(avatarsWrapper, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 70, 0, 0, 0, 0, 0)); arrowView = new ArrowView(context); @@ -472,7 +474,7 @@ public void onAnimationEnd(Animator animation) { avatarsContainer.animate().setInterpolator(interpolator).translationX(0).setDuration(duration).start(); } else { int count = addedChats.size() - 1; - avatarsContainer.animate().setInterpolator(interpolator).translationX(dp(11) * count).setDuration(duration).start(); + avatarsContainer.animate().setInterpolator(interpolator).translationX(dp(13) * count).setDuration(duration).start(); } toAvatar.animate().cancel(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/SelectorBottomSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/SelectorBottomSheet.java index 8ae9dba297..83d6a4e3da 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/SelectorBottomSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/SelectorBottomSheet.java @@ -25,7 +25,6 @@ import org.telegram.messenger.LocaleController; import org.telegram.messenger.MessagesController; import org.telegram.messenger.R; -import org.telegram.messenger.UserConfig; import org.telegram.tgnet.TLObject; import org.telegram.tgnet.TLRPC; import org.telegram.ui.ActionBar.BaseFragment; @@ -48,13 +47,14 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; public class SelectorBottomSheet extends BottomSheetWithRecyclerListView { public interface SelectedObjectsListener { - void onChatsSelected(List chats); + void onChatsSelected(List chats, boolean animated); void onUsersSelected(List users); @@ -86,6 +86,7 @@ default void onShowToast(String text) { private final Map> countriesMap = new HashMap<>(); private final List countriesLetters = new ArrayList<>(); private final List countriesList = new ArrayList<>(); + private final HashMap allSelectedObjects = new LinkedHashMap<>(); private final AnimatedFloat statusBarT; private String query; private SelectorAdapter selectorAdapter; @@ -167,6 +168,7 @@ public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newStat selectedIds.remove(id); } else { selectedIds.add(id); + allSelectedObjects.put(id, user != null ? user : chat); } if ((selectedIds.size() == 11 && type == TYPE_USER) || (selectedIds.size() == (BoostRepository.giveawayAddPeersMax() + 1) && type == TYPE_CHANNEL)) { selectedIds.remove(id); @@ -180,7 +182,11 @@ public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newStat selectedIds.remove(id); searchField.updateSpans(true, selectedIds, () -> updateList(true, false), null); updateList(true, false); - }); + }, this::clearSearchAfterSelectChannel); + } else { + if (chat != null) { + clearSearchAfterSelectChannel(); + } } } if (view instanceof SelectorCountryCell) { @@ -197,10 +203,14 @@ public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newStat return; } searchField.updateSpans(true, selectedIds, () -> updateList(true, false), countriesList); - query = null; - searchField.setText(""); - updateList(false, false); - updateList(true, true); + if (isSearching()) { + query = null; + searchField.setText(""); + updateList(false, false); + updateList(true, true); + } else { + updateList(true, false); + } } }); DefaultItemAnimator itemAnimator = new DefaultItemAnimator(); @@ -225,6 +235,18 @@ public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull R loadData(TYPE_COUNTRY, true, null); } + private void clearSearchAfterSelectChannel() { + if (isSearching()) { + query = null; + searchField.setText(""); + AndroidUtilities.cancelRunOnUIThread(remoteSearchRunnable); + peers.clear(); + peers.addAll(BoostRepository.getMyChannels(currentChat.id)); + updateList(false, false); + updateList(true, true); + } + } + private void save(boolean force) { if (selectedIds.size() == 0 && !force) { return; @@ -232,22 +254,20 @@ private void save(boolean force) { switch (type) { case TYPE_CHANNEL: List selectedChats = new ArrayList<>(); - for (TLRPC.InputPeer peer : peers) { - if (peer instanceof TLRPC.TL_inputPeerChat && selectedIds.contains(-peer.chat_id)) { - selectedChats.add(MessagesController.getInstance(UserConfig.selectedAccount).getChat(peer.chat_id)); - } else if (peer instanceof TLRPC.TL_inputPeerChannel && selectedIds.contains(-peer.channel_id)) { - selectedChats.add(MessagesController.getInstance(UserConfig.selectedAccount).getChat(peer.channel_id)); + for (TLObject object : allSelectedObjects.values()) { + if (object instanceof TLRPC.Chat && selectedIds.contains(-((TLRPC.Chat) object).id)) { + selectedChats.add((TLRPC.Chat) object); } } if (selectedObjectsListener != null) { - selectedObjectsListener.onChatsSelected(selectedChats); + selectedObjectsListener.onChatsSelected(selectedChats, true); } break; case TYPE_USER: List selectedUsers = new ArrayList<>(); - for (TLRPC.InputPeer peer : peers) { - if (peer instanceof TLRPC.TL_inputPeerUser && selectedIds.contains(peer.user_id)) { - selectedUsers.add(MessagesController.getInstance(UserConfig.selectedAccount).getUser(peer.user_id)); + for (TLObject object : allSelectedObjects.values()) { + if (object instanceof TLRPC.User && selectedIds.contains(((TLRPC.User) object).id)) { + selectedUsers.add((TLRPC.User) object); } } if (selectedObjectsListener != null) { @@ -365,6 +385,7 @@ public void prepare(List selectedObjects, int type) { openedIds.clear(); selectedIds.clear(); peers.clear(); + allSelectedObjects.clear(); switch (type) { case TYPE_CHANNEL: @@ -379,23 +400,25 @@ public void prepare(List selectedObjects, int type) { } if (selectedObjects != null) { - for (TLObject selectedChat : selectedObjects) { - if (selectedChat instanceof TLRPC.TL_inputPeerChat) { - selectedIds.add(-((TLRPC.TL_inputPeerChat) selectedChat).chat_id); + for (TLObject selectedItem : selectedObjects) { + long id = 0; + if (selectedItem instanceof TLRPC.TL_inputPeerChat) { + id = -((TLRPC.TL_inputPeerChat) selectedItem).chat_id; } - if (selectedChat instanceof TLRPC.TL_inputPeerChannel) { - selectedIds.add(-((TLRPC.TL_inputPeerChannel) selectedChat).channel_id); + if (selectedItem instanceof TLRPC.TL_inputPeerChannel) { + id = -((TLRPC.TL_inputPeerChannel) selectedItem).channel_id; } - if (selectedChat instanceof TLRPC.Chat) { - selectedIds.add(-((TLRPC.Chat) selectedChat).id); + if (selectedItem instanceof TLRPC.Chat) { + id = -((TLRPC.Chat) selectedItem).id; } - if (selectedChat instanceof TLRPC.User) { - selectedIds.add(((TLRPC.User) selectedChat).id); + if (selectedItem instanceof TLRPC.User) { + id = ((TLRPC.User) selectedItem).id; } - if (selectedChat instanceof TLRPC.TL_help_country) { - long id = ((TLRPC.TL_help_country) selectedChat).default_name.hashCode(); - selectedIds.add(id); + if (selectedItem instanceof TLRPC.TL_help_country) { + id = ((TLRPC.TL_help_country) selectedItem).default_name.hashCode(); } + selectedIds.add(id); + allSelectedObjects.put(id, selectedItem); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/msg/GiveawayMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/msg/GiveawayMessageCell.java index 6acfa288a3..7f6e833f8a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/msg/GiveawayMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/msg/GiveawayMessageCell.java @@ -8,6 +8,7 @@ import static org.telegram.messenger.LocaleController.getString; import android.graphics.Canvas; +import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; @@ -74,6 +75,7 @@ public class GiveawayMessageCell { private final ImageReceiver giftReceiver; private CharSequence[] chatTitles = new CharSequence[10]; + private TLRPC.Chat[] chats = new TLRPC.Chat[10]; private float[] chatTitleWidths = new float[10]; private boolean[] needNewRow = new boolean[10]; private Rect[] clickRect = new Rect[10]; @@ -178,7 +180,7 @@ public boolean checkMotionEvent(MotionEvent event) { } public void setButtonPressed(boolean pressed) { - if (messageObject == null || !messageObject.isGiveaway()) { + if (messageObject == null || !messageObject.isGiveaway() || selectorDrawable == null) { return; } if (pressed) { @@ -338,6 +340,7 @@ public void setMessageContent(MessageObject messageObject, int parentWidth, int if (chat != null) { avatarVisible[i] = true; + chats[i] = chat; CharSequence text = Emoji.replaceEmoji(chat.title, chatTextPaint.getFontMetricsInt(), dp(14), false); chatTitles[i] = TextUtils.ellipsize(text, chatTextPaint, maxWidth * 0.8f, TextUtils.TruncateAt.END); chatTitleWidths[i] = chatTextPaint.measureText(chatTitles[i], 0, chatTitles[i].length()); @@ -356,6 +359,7 @@ public void setMessageContent(MessageObject messageObject, int parentWidth, int avatarImageReceivers[i].setForUserOrChat(chat, avatarDrawables[i]); avatarImageReceivers[i].setImageCoords(0, 0, dp(24), dp(24)); } else { + chats[i] = null; avatarVisible[i] = false; chatTitles[i] = ""; needNewRow[i] = false; @@ -365,6 +369,23 @@ public void setMessageContent(MessageObject messageObject, int parentWidth, int } } + private int getChatColor(TLRPC.Chat chat, Theme.ResourcesProvider resourcesProvider) { + final int color; + int colorId = (chat.flags2 & 64) != 0 ? chat.color : (int) (chat.id % 7); + if (colorId < 7) { + color = Theme.getColor(Theme.keys_avatar_nameInMessage[colorId], resourcesProvider); + } else { + MessagesController.PeerColors peerColors = MessagesController.getInstance(UserConfig.selectedAccount).peerColors; + MessagesController.PeerColor peerColor = peerColors == null ? null : peerColors.getColor(colorId); + if (peerColor != null) { + color = peerColor.getColor1(); + } else { + color = Theme.getColor(Theme.keys_avatar_nameInMessage[0], resourcesProvider); + } + } + return color; + } + public void draw(Canvas canvas, int marginTop, int marginLeft, Theme.ResourcesProvider resourcesProvider) { if (messageObject == null || !messageObject.isGiveaway()) { return; @@ -374,11 +395,6 @@ public void draw(Canvas canvas, int marginTop, int marginLeft, Theme.ResourcesPr selectorDrawable = Theme.createRadSelectorDrawable(selectorColor = Theme.getColor(Theme.key_listSelector), 12, 12); } - int rippleColor = Theme.multAlpha(chatTextPaint.getColor(), Theme.isCurrentThemeDark() ? 0.12f : 0.10f); - if (selectorColor != rippleColor) { - Theme.setSelectorDrawableColor(selectorDrawable, selectorColor = rippleColor, true); - } - textPaint.setColor(Theme.chat_msgTextPaint.getColor()); countriesTextPaint.setColor(Theme.chat_msgTextPaint.getColor()); @@ -392,8 +408,6 @@ public void draw(Canvas canvas, int marginTop, int marginLeft, Theme.ResourcesPr chatBgPaint.setColor(Theme.getColor(Theme.key_chat_inReplyLine, resourcesProvider)); } - chatBgPaint.setAlpha((int) (chatTextPaint.getAlpha() * 0.10f)); - int x = 0, y = 0; canvas.save(); x = marginLeft - dp(4); @@ -435,6 +449,7 @@ public void draw(Canvas canvas, int marginTop, int marginLeft, Theme.ResourcesPr canvas.translate(0, topHeight + dp(6)); y += topHeight + dp(6); + int selectedChatColor = 0; int i = 0; while (i < avatarVisible.length) { if (avatarVisible[i]) { @@ -454,6 +469,13 @@ public void draw(Canvas canvas, int marginTop, int marginLeft, Theme.ResourcesPr k = i; do { + int chatColor = getChatColor(chats[k], resourcesProvider); + if (pressedPos >= 0 && pressedPos == k) { + selectedChatColor = chatColor; + } + chatTextPaint.setColor(chatColor); + chatBgPaint.setColor(chatColor); + chatBgPaint.setAlpha(25); avatarImageReceivers[k].draw(canvas); canvas.drawText(chatTitles[k], 0, chatTitles[k].length(), dp(24 + 6), dp(16), chatTextPaint); chatRect.set(0, 0, chatTitleWidths[k] + dp(24 + 6 + 12), dp(24)); @@ -492,6 +514,10 @@ public void draw(Canvas canvas, int marginTop, int marginLeft, Theme.ResourcesPr canvas.restore(); canvas.restore(); if (pressedPos >= 0) { + int rippleColor = Theme.multAlpha(selectedChatColor, Theme.isCurrentThemeDark() ? 0.12f : 0.10f); + if (selectorColor != rippleColor) { + Theme.setSelectorDrawableColor(selectorDrawable, selectorColor = rippleColor, true); + } selectorDrawable.setBounds(clickRect[pressedPos]); selectorDrawable.draw(canvas); } @@ -551,6 +577,7 @@ private void checkArraysLimits(int channelsCount) { chatTitleWidths = Arrays.copyOf(chatTitleWidths, channelsCount); needNewRow = Arrays.copyOf(needNewRow, channelsCount); clickRect = Arrays.copyOf(clickRect, channelsCount); + chats = Arrays.copyOf(chats, channelsCount); for (int i = oldLength - 1; i < channelsCount; i++) { avatarImageReceivers[i] = new ImageReceiver(parentView); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ReplyMessageLine.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ReplyMessageLine.java index e9095d5312..ecc64a5c4c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ReplyMessageLine.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ReplyMessageLine.java @@ -138,7 +138,12 @@ private void resolveColor(MessageObject messageObject, int colorId, Theme.Resour } } - public int check(MessageObject messageObject, TLRPC.User currentUser, TLRPC.Chat currentChat, Theme.ResourcesProvider resourcesProvider, boolean isReply) { + public static final int TYPE_REPLY = 0; + public static final int TYPE_QUOTE = 1; + public static final int TYPE_CODE = 2; + public static final int TYPE_LINK = 3; + + public int check(MessageObject messageObject, TLRPC.User currentUser, TLRPC.Chat currentChat, Theme.ResourcesProvider resourcesProvider, final int type) { reversedOut = false; emojiDocumentId = 0; if (messageObject == null) { @@ -146,7 +151,7 @@ public int check(MessageObject messageObject, TLRPC.User currentUser, TLRPC.Chat color1 = color2 = color3 = Theme.getColor(Theme.key_chat_inReplyLine, resourcesProvider); backgroundColor = Theme.multAlpha(color1, Theme.isCurrentThemeDark() ? 0.12f : 0.10f); return nameColorAnimated.set(nameColor = Theme.getColor(Theme.key_chat_inReplyNameText, resourcesProvider)); - } else if (!isReply && ( + } else if (type != TYPE_REPLY && ( messageObject.overrideLinkColor >= 0 || messageObject.messageOwner != null && ( (messageObject.isFromUser() || DialogObject.isEncryptedDialog(messageObject.getDialogId())) && currentUser != null || @@ -206,7 +211,7 @@ public int check(MessageObject messageObject, TLRPC.User currentUser, TLRPC.Chat resolveColor(messageObject, colorId, resourcesProvider); backgroundColor = Theme.multAlpha(color1, 0.10f); nameColor = color1; - } else if (isReply && ( + } else if (type == TYPE_REPLY && ( messageObject.overrideLinkColor >= 0 || messageObject.messageOwner != null && messageObject.replyMessageObject != null && @@ -282,7 +287,7 @@ public int check(MessageObject messageObject, TLRPC.User currentUser, TLRPC.Chat backgroundColor = Theme.multAlpha(color3, Theme.isCurrentThemeDark() ? 0.12f : 0.10f); nameColor = Theme.getColor(Theme.key_chat_outReplyNameText, resourcesProvider); } - if (isReply && messageObject != null && messageObject.overrideLinkEmoji != -1) { + if (type == TYPE_REPLY && messageObject != null && messageObject.overrideLinkEmoji != -1) { emojiDocumentId = messageObject.overrideLinkEmoji; } if (emojiDocumentId != 0 && emoji == null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java index 9ace7cc3c3..16c14e0ad6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java @@ -7475,7 +7475,7 @@ private void checkListLoad(ViewPage viewPage, int firstVisibleItem, int lastVisi boolean loadArchivedFromCache = false; boolean load = false; boolean loadFromCache = false; - if (viewPage.dialogsType == 7 || viewPage.dialogsType == 8) { + if (viewPage.dialogsType == DIALOGS_TYPE_7 || viewPage.dialogsType == DIALOGS_TYPE_8) { ArrayList dialogFilters = getMessagesController().getDialogFilters(); if (viewPage.selectedType >= 0 && viewPage.selectedType < dialogFilters.size()) { MessagesController.DialogFilter filter = dialogFilters.get(viewPage.selectedType); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index e49cbbe635..5ac945a0d8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -950,12 +950,7 @@ private void showAttachMenuBot(TLRPC.TL_attachMenuBot attachMenuBot, String star BotWebViewSheet webViewSheet = new BotWebViewSheet(this, getLastFragment().getResourceProvider()); webViewSheet.setParentActivity(this); webViewSheet.requestWebView(currentAccount, attachMenuBot.bot_id, attachMenuBot.bot_id, attachMenuBot.short_name, null, BotWebViewSheet.TYPE_SIMPLE_WEB_VIEW_BUTTON, 0, false, null, null, false, startApp, null, BotWebViewSheet.FLAG_FROM_SIDE_MENU); - BaseFragment lastFragment = getLastFragment(); - if (lastFragment != null) { - lastFragment.showDialog(webViewSheet); - } else { - webViewSheet.show(); - } + webViewSheet.show(); } @Override @@ -4879,12 +4874,7 @@ private void processWebAppBot(final int intentAccount, BotWebViewSheet sheet = new BotWebViewSheet(LaunchActivity.this, lastFragment.getResourceProvider()); sheet.setParentActivity(LaunchActivity.this); sheet.requestWebView(intentAccount, user.id, user.id, null, null, BotWebViewSheet.TYPE_WEB_VIEW_BOT_APP, 0, false, lastFragment, botApp.app, allowWrite.get(), botAppStartParam, user); - BaseFragment currentLastFragment = getLastFragment(); - if (currentLastFragment != null) { - currentLastFragment.showDialog(sheet); - } else { - sheet.show(); - } + sheet.show(); if (botApp.inactive || forceNotInternalForApps) { sheet.showJustAddedBulletin(); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PaymentFormActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PaymentFormActivity.java index 124464bdd0..930f861f86 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PaymentFormActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PaymentFormActivity.java @@ -3385,6 +3385,8 @@ public void currentPasswordUpdated(TLRPC.account_Password password) { paymentFormCallback.onInvoiceStatusChanged(invoiceStatus); } finishFragment(); + } else if (invoiceStatus == InvoiceStatus.PAID && !isFinishing()) { + finishFragment(); } }, 500); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index 0b68e7e510..5c31f86b3a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -5647,7 +5647,7 @@ public void invalidate() { qualityPicker.updateSelectedCount(0, false); qualityPicker.setTranslationY(dp(120)); qualityPicker.doneButton.setText(LocaleController.getString("Done", R.string.Done).toUpperCase()); - qualityPicker.doneButton.setTextColor(getThemedColor(Theme.key_dialogFloatingButton)); + qualityPicker.doneButton.setTextColor(getThemedColor(Theme.key_chat_editMediaButton)); containerView.addView(qualityPicker, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM | Gravity.LEFT)); qualityPicker.cancelButton.setOnClickListener(view -> { selectedCompression = previousCompression; @@ -6085,7 +6085,7 @@ public void setTranslationY(float translationY) { pickerViewSendButton = new ImageView(parentActivity); pickerViewSendButton.setScaleType(ImageView.ScaleType.CENTER); - pickerViewSendDrawable = Theme.createSimpleSelectorCircleDrawable(dp(48), getThemedColor(Theme.key_dialogFloatingButton), getThemedColor(Build.VERSION.SDK_INT >= 21 ? Theme.key_dialogFloatingButtonPressed : Theme.key_dialogFloatingButton)); + pickerViewSendDrawable = Theme.createSimpleSelectorCircleDrawable(dp(48), getThemedColor(Theme.key_chat_editMediaButton), getThemedColor(Build.VERSION.SDK_INT >= 21 ? Theme.key_dialogFloatingButtonPressed : Theme.key_chat_editMediaButton)); pickerViewSendButton.setBackgroundDrawable(pickerViewSendDrawable); pickerViewSendButton.setImageResource(R.drawable.msg_input_send_mini); pickerViewSendButton.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingIcon), PorterDuff.Mode.MULTIPLY)); @@ -6548,7 +6548,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { checkImageView.setHasBorder(true); checkImageView.setSize(34); checkImageView.setCheckOffset(dp(1)); - checkImageView.setColor(getThemedColor(Theme.key_dialogFloatingButton), 0xffffffff); + checkImageView.setColor(getThemedColor(Theme.key_chat_editMediaButton), 0xffffffff); checkImageView.setVisibility(View.GONE); containerView.addView(checkImageView, LayoutHelper.createFrame(34, 34, Gravity.RIGHT | Gravity.TOP, 0, rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90 ? 61 : 71, 11, 0)); if (isStatusBarVisible()) { @@ -7479,7 +7479,7 @@ public void onAnimationEnd(Animator animation) { return; } if (photoCropView.mirror()) { - mirrorItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingButton), PorterDuff.Mode.MULTIPLY)); + mirrorItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_editMediaButton), PorterDuff.Mode.MULTIPLY)); } else { mirrorItem.setColorFilter(null); } @@ -7555,7 +7555,7 @@ public void onAnimationEnd(Animator animation) { photoCropView.wheelView.setRotated(false); if (Math.abs(diff) > 0) { if (photoCropView.rotate(diff)) { - rotateItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingButton), PorterDuff.Mode.MULTIPLY)); + rotateItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_editMediaButton), PorterDuff.Mode.MULTIPLY)); } else { rotateItem.setColorFilter(null); } @@ -8234,15 +8234,15 @@ private void checkBufferedProgress(float progress) { } public void updateColors() { - int color = getThemedColor(Theme.key_dialogFloatingButton); + int color = getThemedColor(Theme.key_chat_editMediaButton); if (pickerViewSendButton != null) { Drawable drawable = pickerViewSendButton.getBackground(); Theme.setSelectorDrawableColor(drawable, color, false); - Theme.setSelectorDrawableColor(drawable, getThemedColor(Build.VERSION.SDK_INT >= 21 ? Theme.key_dialogFloatingButtonPressed : Theme.key_dialogFloatingButton), true); + Theme.setSelectorDrawableColor(drawable, getThemedColor(Build.VERSION.SDK_INT >= 21 ? Theme.key_dialogFloatingButtonPressed : Theme.key_chat_editMediaButton), true); pickerViewSendButton.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingIcon), PorterDuff.Mode.MULTIPLY)); } if (checkImageView != null) { - checkImageView.setColor(getThemedColor(Theme.key_dialogFloatingButton), 0xffffffff); + checkImageView.setColor(getThemedColor(Theme.key_chat_editMediaButton), 0xffffffff); } PorterDuffColorFilter filter = new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY); if (paintItem != null && paintItem.getColorFilter() != null) { @@ -9620,17 +9620,17 @@ private void applyCurrentEditMode() { if (currentEditMode == EDIT_MODE_CROP) { entry.isCropped = true; if (entry.isCropped) { - cropItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingButton), PorterDuff.Mode.MULTIPLY)); + cropItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_editMediaButton), PorterDuff.Mode.MULTIPLY)); } else { cropItem.setColorFilter(null); } } else if (currentEditMode == EDIT_MODE_FILTER) { entry.isFiltered = true; - tuneItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingButton), PorterDuff.Mode.MULTIPLY)); + tuneItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_editMediaButton), PorterDuff.Mode.MULTIPLY)); } else if (currentEditMode == EDIT_MODE_PAINT) { if (hasChanged) { entry.isPainted = true; - paintItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingButton), PorterDuff.Mode.MULTIPLY)); + paintItem.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_editMediaButton), PorterDuff.Mode.MULTIPLY)); } } @@ -10144,7 +10144,7 @@ public void onAnimationEnd(Animator animation) { photoCropView.onAppear(); editorDoneLayout.doneButton.setText(LocaleController.getString("Crop", R.string.Crop)); - editorDoneLayout.doneButton.setTextColor(getThemedColor(Theme.key_dialogFloatingButton)); + editorDoneLayout.doneButton.setTextColor(getThemedColor(Theme.key_chat_editMediaButton)); changeModeAnimation = new AnimatorSet(); ArrayList arrayList = new ArrayList<>(); @@ -12419,7 +12419,7 @@ private void setIsAboutToSwitchToIndex(int index, boolean init, boolean animated } updateCaptionTextForCurrentPhoto(object); - PorterDuffColorFilter filter = new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingButton), PorterDuff.Mode.MULTIPLY); + PorterDuffColorFilter filter = new PorterDuffColorFilter(getThemedColor(Theme.key_chat_editMediaButton), PorterDuff.Mode.MULTIPLY); captionEdit.setIsVideo(isVideo); captionEdit.setTimer(ttl); paintItem.setColorFilter(isPainted ? filter : null); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SelectAnimatedEmojiDialog.java b/TMessagesProj/src/main/java/org/telegram/ui/SelectAnimatedEmojiDialog.java index 43a1910ba5..f1ac9be341 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SelectAnimatedEmojiDialog.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SelectAnimatedEmojiDialog.java @@ -1,6 +1,7 @@ package org.telegram.ui; import static org.telegram.messenger.AndroidUtilities.dp; +import static org.telegram.messenger.AndroidUtilities.translitSafe; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -27,8 +28,11 @@ import android.os.Parcelable; import android.os.SystemClock; import android.text.Editable; +import android.text.SpannableString; +import android.text.Spanned; import android.text.TextUtils; import android.text.TextWatcher; +import android.text.style.ForegroundColorSpan; import android.util.Log; import android.util.LongSparseArray; import android.util.SparseArray; @@ -1394,6 +1398,7 @@ protected void onStart() { private String lastQuery; private ArrayList searchResult; private ArrayList stickersSearchResult; + private ArrayList searchSets; private ValueAnimator gridSwitchAnimator; public void switchGrids(boolean search) { @@ -1436,6 +1441,9 @@ public void onAnimationEnd(Animator animation) { gridSwitchAnimator = null; if (!search && searchResult != null) { searchResult.clear(); + if (searchSets != null) { + searchSets.clear(); + } searchAdapter.updateRows(false); } } @@ -1450,9 +1458,9 @@ public void onAnimationEnd(Animator animation) { .setDuration(160) .start(); if (gridSearch && liftUp) { - emojiSearchGridView.setPadding(dp(5), dp(54), dp(5), dp(2)); + emojiSearchGridView.setPadding(dp(5), dp(54), dp(5), dp(36 + 2)); } else { - emojiSearchGridView.setPadding(dp(5), dp(54), dp(5), dp(38)); + emojiSearchGridView.setPadding(dp(5), dp(54), dp(5), dp(36 + 2)); } checkScroll(); } @@ -1610,12 +1618,18 @@ public void search(String query, boolean liftUp, boolean delay) { if (searchResult != null) { searchResult.clear(); } + if (searchSets != null) { + searchSets.clear(); + } searchAdapter.updateRows(false); } else if (!query.equals(lastQuery)) { AndroidUtilities.runOnUIThread(clearSearchRunnable = () -> { if (searchResult != null) { searchResult.clear(); } + if (searchSets != null) { + searchSets.clear(); + } searchAdapter.updateRows(true); }, 120); } @@ -1632,6 +1646,7 @@ public void search(String query, boolean liftUp, boolean delay) { final boolean queryFullyConsistsOfEmojis = Emoji.fullyConsistsOfEmojis(query); final ArrayList> emojiArrays = new ArrayList<>(); final HashMap, String> emojiStickers = new HashMap<>(); + final ArrayList sets = new ArrayList<>(); Utilities.doCallbacks( next -> { if (queryFullyConsistsOfEmojis) { @@ -1768,6 +1783,49 @@ public void search(String query, boolean liftUp, boolean delay) { }, false); } }, + next -> { + ArrayList stickerSets = MediaDataController.getInstance(currentAccount).getStickerSets(MediaDataController.TYPE_EMOJIPACKS); + final HashSet addedSets = new HashSet<>(); + final String q = translitSafe(query), sq = " " + q; + if (stickerSets != null) { + for (int i = 0; i < stickerSets.size(); ++i) { + TLRPC.TL_messages_stickerSet set = stickerSets.get(i); + if (set == null || set.set == null || set.set.title == null || set.documents == null || addedSets.contains(set.set.id)) continue; + final String title = translitSafe(set.set.title); + if (title.startsWith(q) || title.contains(sq)) { + sets.add(new SetTitleDocument(title)); + sets.addAll(set.documents); + addedSets.add(set.set.id); + } + } + } + ArrayList featuredSets = MediaDataController.getInstance(currentAccount).getFeaturedEmojiSets(); + if (featuredSets != null) { + for (int i = 0; i < featuredSets.size(); ++i) { + TLRPC.StickerSetCovered set = featuredSets.get(i); + if (set == null || set.set == null || set.set.title == null || addedSets.contains(set.set.id)) continue; + final String title = translitSafe(set.set.title); + if (title.startsWith(q) || title.contains(sq)) { + ArrayList documents = null; + if (set instanceof TLRPC.TL_stickerSetNoCovered) { + TLRPC.TL_messages_stickerSet fullSet = MediaDataController.getInstance(currentAccount).getStickerSet(MediaDataController.getInputStickerSet(set.set), set.set.hash, true); + if (fullSet != null) { + documents = fullSet.documents; + } + } else if (set instanceof TLRPC.TL_stickerSetFullCovered) { + documents = ((TLRPC.TL_stickerSetFullCovered) set).documents; + } else { + documents = set.covers; + } + if (documents == null || documents.size() == 0) continue; + sets.add(new SetTitleDocument(set.set.title)); + sets.addAll(documents); + addedSets.add(set.set.id); + } + } + } + next.run(); + }, next -> AndroidUtilities.runOnUIThread(() -> { if (clearSearchRunnable != null) { AndroidUtilities.cancelRunOnUIThread(clearSearchRunnable); @@ -1787,6 +1845,11 @@ public void search(String query, boolean liftUp, boolean delay) { } else { searchResult.clear(); } + if (searchSets == null) { + searchSets = new ArrayList<>(); + } else { + searchSets.clear(); + } if (stickersSearchResult == null) { stickersSearchResult = new ArrayList<>(); } else { @@ -1806,6 +1869,7 @@ public void search(String query, boolean liftUp, boolean delay) { for (long documentId : documentIds) { searchResult.add(ReactionsLayoutInBubble.VisibleReaction.fromCustomEmoji(documentId)); } + searchSets.addAll(sets); for (ArrayList array : emojiArrays) { stickersSearchResult.addAll(array); } @@ -1833,6 +1897,7 @@ private class SearchAdapter extends RecyclerListView.SelectionAdapter { int emojiStartRow; int emojiHeaderRow = -1; int stickersHeaderRow = -1; + int setsStartRow; @Override public boolean isEnabled(RecyclerView.ViewHolder holder) { @@ -1879,6 +1944,12 @@ public int getItemViewType(int position) { return VIEW_TYPE_EMOJI; } } + if (position - setsStartRow >= 0 && position - setsStartRow < searchSets.size()) { + if (searchSets.get(position - setsStartRow) instanceof SetTitleDocument) { + return VIEW_TYPE_HEADER; + } + return VIEW_TYPE_EMOJI; + } return VIEW_TYPE_REACTION; } @@ -1886,7 +1957,12 @@ public int getItemViewType(int position) { public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { if (holder.getItemViewType() == VIEW_TYPE_HEADER) { HeaderView header = (HeaderView) holder.itemView; - if (position == emojiHeaderRow) { + if (searchSets != null && (position - setsStartRow) >= 0 && (position - setsStartRow) < searchSets.size()) { + TLRPC.Document d = searchSets.get(position - setsStartRow); + if (d instanceof SetTitleDocument) { + header.setText(((SetTitleDocument) d).title, lastQuery, false); + } + } else if (position == emojiHeaderRow) { header.setText(LocaleController.getString("Emoji", R.string.Emoji), false); } else { header.setText(LocaleController.getString("AccDescrStickers", R.string.AccDescrStickers), false); @@ -1968,11 +2044,26 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi imageView.setPadding(AndroidUtilities.dp(1), AndroidUtilities.dp(1), AndroidUtilities.dp(1), AndroidUtilities.dp(1)); boolean selected = false; imageView.setDrawable(null); + Long documentId = null; + TLRPC.Document document = null; if (searchResult != null && position >= 0 && position < searchResult.size()) { - final long documentId = searchResult.get(position).documentId; - imageView.span = new AnimatedEmojiSpan(documentId, null); - imageView.document = imageView.span.document; - selected = selectedDocumentIds.contains(documentId); + documentId = searchResult.get(position).documentId; + } else if (searchSets != null && (position - setsStartRow) >= 0 && (position - setsStartRow) < searchSets.size()) { + document = searchSets.get(position - setsStartRow); + if (document instanceof SetTitleDocument) { + document = null; + } + } + if (documentId != null || document != null) { + if (document != null) { + imageView.span = new AnimatedEmojiSpan(document, null); + imageView.document = document; + selected = selectedDocumentIds.contains(document.id); + } else { + imageView.span = new AnimatedEmojiSpan(documentId, null); + imageView.document = imageView.span.document; + selected = selectedDocumentIds.contains(documentId); + } AnimatedEmojiDrawable drawable = emojiSearchGridView.animatedEmojiDrawables.get(imageView.span.getDocumentId()); if (drawable == null) { @@ -1999,6 +2090,7 @@ public void updateRows(boolean diff) { } ArrayList prevRowHashCodes = new ArrayList<>(rowHashCodes); + setsStartRow = -1; count = 0; rowHashCodes.clear(); @@ -2028,6 +2120,11 @@ public void updateRows(boolean diff) { } } + if (searchSets != null) { + setsStartRow = count; + count += searchSets.size(); + } + // if (diff) { // DiffUtil.calculateDiff(new DiffUtil.Callback() { // @Override @@ -2481,6 +2578,20 @@ public void setText(String text, boolean lock) { updateLock(lock, false); } + public void setText(String text, String query, boolean lock) { + CharSequence finalText = text; + if (text != null && query != null) { + final int index = text.toLowerCase().indexOf(query.toLowerCase()); + if (index >= 0) { + SpannableString spannableString = new SpannableString(text); + spannableString.setSpan(new ForegroundColorSpan(Theme.getColor(Theme.key_chat_emojiPanelStickerSetNameHighlight, resourcesProvider)), index, index + query.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + finalText = spannableString; + } + } + this.textView.setText(finalText); + updateLock(lock, false); + } + private float lockT; private ValueAnimator lockAnimator; @@ -5459,4 +5570,11 @@ public interface BackgroundDelegate { public boolean prevWindowKeyboardVisible() { return false; } + + public static class SetTitleDocument extends TLRPC.Document { + public final String title; + public SetTitleDocument(String title) { + this.title = title; + } + } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/StatisticActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/StatisticActivity.java index 47062a7366..72475b6f03 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/StatisticActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/StatisticActivity.java @@ -373,6 +373,11 @@ public void didReceivedNotification(int id, int account, Object... args) { TLRPC.Chat chat = (TLRPC.Chat) args[0]; boolean isGiveaway = (boolean) args[1]; List fragmentStack = getParentLayout().getFragmentStack(); + BaseFragment chatEditFragment = fragmentStack.size() >= 2 ? fragmentStack.get(fragmentStack.size() - 2) : null; + if (chatEditFragment instanceof ChatEditActivity) { + getParentLayout().removeFragmentFromStack(chatEditFragment); + } + fragmentStack = getParentLayout().getFragmentStack(); BaseFragment profileFragment = fragmentStack.size() >= 2 ? fragmentStack.get(fragmentStack.size() - 2) : null; if (isGiveaway) { BaseFragment chatFragment = fragmentStack.size() >= 3 ? fragmentStack.get(fragmentStack.size() - 3) : null; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Stories/DarkThemeResourceProvider.java b/TMessagesProj/src/main/java/org/telegram/ui/Stories/DarkThemeResourceProvider.java index 327871467c..2eb82b3b92 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/DarkThemeResourceProvider.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/DarkThemeResourceProvider.java @@ -97,7 +97,7 @@ public DarkThemeResourceProvider() { sparseIntArray.put(Theme.key_chat_emojiPanelShadowLine, ColorUtils.setAlphaComponent(Color.BLACK, 30)); sparseIntArray.put(Theme.key_chat_emojiPanelBackspace, ColorUtils.setAlphaComponent(Color.WHITE, 125)); sparseIntArray.put(Theme.key_divider, 0xFF000000); - sparseIntArray.put(Theme.key_dialogFloatingButton, -15033089); + sparseIntArray.put(Theme.key_chat_editMediaButton, -15033089); sparseIntArray.put(Theme.key_dialogFloatingIcon, 0xffffffff); sparseIntArray.put(Theme.key_graySection, 0xFF292929); sparseIntArray.put(Theme.key_graySectionText, -8158332); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Stories/PeerStoriesView.java b/TMessagesProj/src/main/java/org/telegram/ui/Stories/PeerStoriesView.java index 783d416c61..cbd8bdabbe 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/PeerStoriesView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/PeerStoriesView.java @@ -76,6 +76,7 @@ import org.telegram.messenger.MediaDataController; import org.telegram.messenger.MessageObject; import org.telegram.messenger.MessagesController; +import org.telegram.messenger.MessagesStorage; import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.NotificationsController; import org.telegram.messenger.R; @@ -4863,7 +4864,16 @@ public boolean allowScreenshots() { return uploadingStory.entry.allowScreenshots; } if (storyItem != null) { - return !storyItem.noforwards; + if (storyItem.noforwards) { + return false; + } + if (storyItem.pinned) { + final long did = storyItem.dialogId; + final TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-did); + if (chat != null && chat.noforwards) { + return false; + } + } } return true; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Stories/StoryPositionView.java b/TMessagesProj/src/main/java/org/telegram/ui/Stories/StoryPositionView.java index 8c058ddbc8..27db889f33 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/StoryPositionView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/StoryPositionView.java @@ -49,8 +49,8 @@ public void draw(Canvas canvas, float alpha, int linesPosition, int linesCount, float top = headerView.getY() + headerView.titleView.getTop() + textDrawable.getHeight() / 2f - 1;// + //(headerView.titleView.getMeasuredHeight() - textDrawable.getHeight()) / 2f + AndroidUtilities.dp(1); int rightPadding = (int) textDrawable.getCurrentWidth(); headerView.titleView.setRightPadding(rightPadding); - float left = AndroidUtilities.dp(4) + headerView.getLeft() + headerView.titleView.getLeft() + headerView.titleView.getTextWidth(); - left -= Utilities.clamp(headerView.titleView.getTextWidth() + rightPadding - headerView.titleView.getWidth(), rightPadding, 0); + float left = AndroidUtilities.dp(4) + headerView.getLeft() + headerView.titleView.getLeft() + headerView.titleView.getTextWidth() + headerView.titleView.getRightDrawableWidth(); + left -= Utilities.clamp(headerView.titleView.getTextWidth() + headerView.titleView.getRightDrawableWidth() + rightPadding - headerView.titleView.getWidth(), rightPadding, 0); canvas.translate(left, top); float horizontalPadding = AndroidUtilities.dp(8); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/CaptionContainerView.java b/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/CaptionContainerView.java index e88a1443b1..df224c8c0b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/CaptionContainerView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/CaptionContainerView.java @@ -294,7 +294,7 @@ public void afterTextChanged(Editable s) { ScaleStateListAnimator.apply(applyButton, 0.05f, 1.25f); applyButtonCheck = context.getResources().getDrawable(R.drawable.input_done).mutate(); applyButtonCheck.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogFloatingIcon), PorterDuff.Mode.SRC_IN)); - applyButtonDrawable = new CombinedDrawable(Theme.createCircleDrawable(AndroidUtilities.dp(16), Theme.getColor(Theme.key_dialogFloatingButton, resourcesProvider)), applyButtonCheck, 0, AndroidUtilities.dp(1)); + applyButtonDrawable = new CombinedDrawable(Theme.createCircleDrawable(AndroidUtilities.dp(16), Theme.getColor(Theme.key_chat_editMediaButton, resourcesProvider)), applyButtonCheck, 0, AndroidUtilities.dp(1)); applyButtonDrawable.setCustomSize(AndroidUtilities.dp(32), AndroidUtilities.dp(32)); applyButton.setImageDrawable(applyButtonDrawable); applyButton.setScaleType(ImageView.ScaleType.CENTER); @@ -985,7 +985,7 @@ public int getSelectionLength() { public void updateColors(Theme.ResourcesProvider resourcesProvider) { this.resourcesProvider = resourcesProvider; applyButtonCheck.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogFloatingIcon), PorterDuff.Mode.SRC_IN)); - applyButtonDrawable.setBackgroundDrawable(Theme.createCircleDrawable(AndroidUtilities.dp(16), Theme.getColor(Theme.key_dialogFloatingButton, resourcesProvider))); + applyButtonDrawable.setBackgroundDrawable(Theme.createCircleDrawable(AndroidUtilities.dp(16), Theme.getColor(Theme.key_chat_editMediaButton, resourcesProvider))); } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/EmojiBottomSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/EmojiBottomSheet.java index 298ec24620..7a73bb6add 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/EmojiBottomSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/EmojiBottomSheet.java @@ -57,6 +57,7 @@ import org.telegram.messenger.DocumentObject; import org.telegram.messenger.Emoji; import org.telegram.messenger.FileLoader; +import org.telegram.messenger.FileLog; import org.telegram.messenger.ImageLoader; import org.telegram.messenger.ImageLocation; import org.telegram.messenger.ImageReceiver; @@ -82,6 +83,7 @@ import org.telegram.ui.Cells.ContextLinkCell; import org.telegram.ui.Cells.StickerSetNameCell; import org.telegram.ui.Components.AnimatedEmojiDrawable; +import org.telegram.ui.Components.AnimatedEmojiSpan; import org.telegram.ui.Components.AnimatedFileDrawable; import org.telegram.ui.Components.AnimatedFloat; import org.telegram.ui.Components.BackupImageView; @@ -1391,6 +1393,7 @@ public void bindView(View view, int position, int viewType) { NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.stickersDidLoad); NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.groupStickersDidLoad); + FileLog.disableGson(true); MediaDataController.getInstance(currentAccount).checkStickers(MediaDataController.TYPE_EMOJIPACKS); MediaDataController.getInstance(currentAccount).checkFeaturedEmoji(); @@ -1426,6 +1429,7 @@ public void dismiss() { NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.groupStickersDidLoad); closeKeyboard(); super.dismiss(); + FileLog.disableGson(false); } private Utilities.Callback2 drawBlurBitmap; @@ -1706,7 +1710,7 @@ protected void onAttachedToWindow() { super.onAttachedToWindow(); attached = true; if (drawable != null) { - drawable.addView(listView); + drawable.addView(this); } if (imageReceiver != null) { imageReceiver.onAttachedToWindow(); @@ -1718,7 +1722,7 @@ protected void onDetachedFromWindow() { super.onDetachedFromWindow(); attached = false; if (drawable != null) { - drawable.removeView(listView); + drawable.removeView(this); } if (imageReceiver != null) { imageReceiver.onDetachedFromWindow(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/TextMessageEnterTransition.java b/TMessagesProj/src/main/java/org/telegram/ui/TextMessageEnterTransition.java index 79dbeec3ef..e29da56d93 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/TextMessageEnterTransition.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/TextMessageEnterTransition.java @@ -545,7 +545,7 @@ public void onDraw(Canvas canvas) { if (messageView.replyLine == null) { messageView.replyLine = new ReplyMessageLine(messageView); } - messageView.replyLine.check(messageView.getMessageObject(), messageView.getCurrentUser(), messageView.getCurrentChat(), resourcesProvider, true); + messageView.replyLine.check(messageView.getMessageObject(), messageView.getCurrentUser(), messageView.getCurrentChat(), resourcesProvider, ReplyMessageLine.TYPE_REPLY); int replyMessageColor; int replyOwnerMessageColor; diff --git a/TMessagesProj/src/main/res/values/strings.xml b/TMessagesProj/src/main/res/values/strings.xml index 2ae80b0ce1..621f9e89f8 100644 --- a/TMessagesProj/src/main/res/values/strings.xml +++ b/TMessagesProj/src/main/res/values/strings.xml @@ -489,7 +489,11 @@ Leave channel Settings JOIN - APPLY TO JOIN GROUP + APPLY TO JOIN CHANNEL + JOIN REQUEST SENT + JOIN + APPLY TO JOIN GROUP + JOIN REQUEST SENT Broadcast Silent Broadcast What is a Channel? @@ -731,6 +735,7 @@ Select from gallery Search web Statistics + Statistics and Boosts Add Bot Add bot as admin Add bot as admin? @@ -5954,7 +5959,6 @@ Additional App Icons Unlock a wider range of app icons by subscribing to Telegram Premium. I accept the *Terms of Service* of %1$s. - JOIN REQUEST SENT Are you sure you want to revoke these links?\n\nThe groups will become private. Are you sure you want to revoke these links?\n\nThe channels will become private. Do you want to clear all your recent stickers? @@ -7242,6 +7246,8 @@ list of viewers. Open Gift Link Save Recipients %s just started a giveaway of Telegram Premium subscriptions to its followers. + Delete announcement + Deleting this message won\'t cancel the giveaway - the winners will still be selected on **%s**.\n\nOnce deleted, the Giveaway Announcement cannot be restored. %d boost %d boost %d boosts @@ -7294,6 +7300,7 @@ list of viewers. To be distributed %1$dm Giveaway + Channel started a giveaway The recipient will be selected when the giveaway ends. Incomplete Giveaway No recipient @@ -7496,6 +7503,8 @@ list of viewers. Wait until the boost is available or get **%1$d** more boosts by gifting a **Telegram Premium** subscription. Boost Again Reassign Boost + Start Giveaway + Are you sure you want to start the giveaway now? More Boosts Needed %1$d boost reassigned from %2$s %1$d boosts reassigned from %2$s diff --git a/gradle.properties b/gradle.properties index 29279e28ee..b03f11abb0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,8 +13,8 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true #Sat Mar 12 05:53:50 MSK 2016 -APP_VERSION_CODE=4082 -APP_VERSION_NAME=10.2.6 +APP_VERSION_CODE=4087 +APP_VERSION_NAME=10.2.9 APP_PACKAGE=org.telegram.messenger RELEASE_KEY_PASSWORD=android RELEASE_KEY_ALIAS=androidkey