From be2fe58f2b5a1ec3bf6c40c7ee4b359f4fc07374 Mon Sep 17 00:00:00 2001 From: vkryl <6242627+vkryl@users.noreply.github.com> Date: Mon, 4 Dec 2023 23:27:24 +0900 Subject: [PATCH 1/9] `ViewPagerController`: call `onFocus` when current item is fully visible --- .../navigation/ViewPagerController.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/src/main/java/org/thunderdog/challegram/navigation/ViewPagerController.java b/app/src/main/java/org/thunderdog/challegram/navigation/ViewPagerController.java index e3ee15239f..5d4afffc55 100644 --- a/app/src/main/java/org/thunderdog/challegram/navigation/ViewPagerController.java +++ b/app/src/main/java/org/thunderdog/challegram/navigation/ViewPagerController.java @@ -227,6 +227,7 @@ protected void onDraw (Canvas c) { adapter = new ViewPagerAdapter(context, this); addAttachStateListener(attachListener); + addFocusListener(focusListener); pager = new RtlViewPager(context); pager.setLayoutParams(params); pager.setOverScrollMode(Config.HAS_NICE_OVER_SCROLL_EFFECT ? View.OVER_SCROLL_IF_CONTENT_SCROLLS : View.OVER_SCROLL_NEVER); @@ -267,6 +268,7 @@ public void onPageScrollStateChanged (int state) { } private void updateControllerState (ViewController c, int position) { boolean attachState = c.getAttachState(); boolean desiredAttachState = adapter.attachedControllers.contains(c); + if (desiredAttachState) { if (currentPositionOffset == 0f || Math.abs(currentPositionOffset) == 1f) { desiredAttachState = (int) (currentPosition + currentPositionOffset) == position; @@ -274,15 +276,32 @@ private void updateControllerState (ViewController c, int position) { desiredAttachState = position == currentPosition || position == currentPosition + Math.signum(currentPositionOffset); } } + + boolean isFocused = c.isFocused(); + boolean desiredFocusState = desiredAttachState && isFocused(); + if (desiredFocusState) { + desiredFocusState = currentPositionOffset == 0f && position == currentPosition; + } + + if (isFocused != desiredFocusState && !desiredFocusState) { + c.onBlur(); + } if (attachState != desiredAttachState) { c.onAttachStateChanged(navigationController, desiredAttachState); } + if (isFocused != desiredFocusState && desiredFocusState) { + c.onFocus(); + } } private final ViewController.AttachListener attachListener = (context, navigation, isAttached) -> { updateAttachedControllers(); }; + private final ViewController.FocusStateListener focusListener = (c, isFocused) -> { + updateAttachedControllers(); + }; + private void updateAttachedControllers () { for (ViewController c : adapter.attachedControllers) { updateControllerState(c, adapter.getControllerPosition(c)); From ace127c8ff997c1050cda4583b135e5888d43499 Mon Sep 17 00:00:00 2001 From: vkryl <6242627+vkryl@users.noreply.github.com> Date: Mon, 4 Dec 2023 23:31:24 +0900 Subject: [PATCH 2/9] `ViewPagerController`: pass current state to children controllers --- .../thunderdog/challegram/navigation/ViewPagerController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/thunderdog/challegram/navigation/ViewPagerController.java b/app/src/main/java/org/thunderdog/challegram/navigation/ViewPagerController.java index 5d4afffc55..a97c52ab33 100644 --- a/app/src/main/java/org/thunderdog/challegram/navigation/ViewPagerController.java +++ b/app/src/main/java/org/thunderdog/challegram/navigation/ViewPagerController.java @@ -267,7 +267,7 @@ public void onPageScrollStateChanged (int state) { } private void updateControllerState (ViewController c, int position) { boolean attachState = c.getAttachState(); - boolean desiredAttachState = adapter.attachedControllers.contains(c); + boolean desiredAttachState = getAttachState() && adapter.attachedControllers.contains(c); if (desiredAttachState) { if (currentPositionOffset == 0f || Math.abs(currentPositionOffset) == 1f) { From b28dff6fc1316cb62cf092c23928bb6f08b041c3 Mon Sep 17 00:00:00 2001 From: vkryl <6242627+vkryl@users.noreply.github.com> Date: Wed, 6 Dec 2023 20:44:35 +0900 Subject: [PATCH 3/9] `RateLimiter`: update execution time prior to invoking runnable --- .../main/java/org/thunderdog/challegram/util/RateLimiter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/thunderdog/challegram/util/RateLimiter.java b/app/src/main/java/org/thunderdog/challegram/util/RateLimiter.java index 55d5340374..52941693d1 100644 --- a/app/src/main/java/org/thunderdog/challegram/util/RateLimiter.java +++ b/app/src/main/java/org/thunderdog/challegram/util/RateLimiter.java @@ -62,9 +62,9 @@ public void run () { private boolean runImpl (boolean byTimeout) { if (byTimeout || !delayFirstExecution) { - act.run(); lastExecutionTime = SystemClock.uptimeMillis(); isScheduled = false; + act.run(); return true; } return false; From 410e65489f9d340c01065af881c5c8fa75ee83ff Mon Sep 17 00:00:00 2001 From: vkryl <6242627+vkryl@users.noreply.github.com> Date: Thu, 7 Dec 2023 08:27:36 +0900 Subject: [PATCH 4/9] Upgraded TDLib to tdlib/td@85c8c19 --- .../component/chat/MediaPreview.java | 2 +- .../component/chat/MessagePreviewView.java | 10 +- .../component/chat/PinnedMessagesBar.java | 10 +- .../component/chat/ReplyBarView.java | 6 +- .../component/chat/ReplyComponent.java | 10 +- .../org/thunderdog/challegram/core/Lang.java | 3 +- .../challegram/data/ContentPreview.java | 12 ++- .../org/thunderdog/challegram/data/TD.java | 11 ++- .../thunderdog/challegram/data/TGMessage.java | 32 ++++-- .../challegram/data/TGMessageService.java | 13 ++- .../challegram/telegram/ChatListener.java | 1 + .../thunderdog/challegram/telegram/Tdlib.java | 58 ++++++++++- .../challegram/telegram/TdlibListeners.java | 97 +++++++------------ .../telegram/TdlibOptionListener.java | 1 + .../challegram/telegram/TdlibSender.java | 3 +- .../challegram/telegram/TdlibUi.java | 2 +- .../ui/ChatStatisticsController.java | 56 +++++++---- .../challegram/ui/MessagesController.java | 16 +-- .../ui/StickersTrendingController.java | 53 ++++++++-- app/src/main/res/values/strings.xml | 3 + tdlib | 2 +- vkryl/td | 2 +- 22 files changed, 266 insertions(+), 137 deletions(-) diff --git a/app/src/main/java/org/thunderdog/challegram/component/chat/MediaPreview.java b/app/src/main/java/org/thunderdog/challegram/component/chat/MediaPreview.java index b2a0f079fc..760a47652e 100644 --- a/app/src/main/java/org/thunderdog/challegram/component/chat/MediaPreview.java +++ b/app/src/main/java/org/thunderdog/challegram/component/chat/MediaPreview.java @@ -289,7 +289,7 @@ public static MediaPreview valueOf (Tdlib tdlib, TdApi.Message message, @Nullabl break; } default: { - Td.assertMessageContent_ea2cfacf(); + Td.assertMessageContent_afad899a(); break; } } diff --git a/app/src/main/java/org/thunderdog/challegram/component/chat/MessagePreviewView.java b/app/src/main/java/org/thunderdog/challegram/component/chat/MessagePreviewView.java index 41a97ada73..e85cea4ed0 100644 --- a/app/src/main/java/org/thunderdog/challegram/component/chat/MessagePreviewView.java +++ b/app/src/main/java/org/thunderdog/challegram/component/chat/MessagePreviewView.java @@ -135,7 +135,7 @@ public MessagePreviewView (Context context, Tdlib tdlib) { private static class DisplayData implements Destroyable { public final Tdlib tdlib; public final TdApi.Message message; - public final @Nullable TdApi.FormattedText quote; + public final @Nullable TdApi.InputTextQuote quote; public final @Options int options; public @Nullable TdApi.SearchMessagesFilter filter; public @Nullable String forcedTitle; @@ -143,7 +143,7 @@ private static class DisplayData implements Destroyable { public @Nullable LinkPreview linkPreview; public @Nullable View.OnClickListener onMediaClickListener; - public DisplayData (Tdlib tdlib, TdApi.Message message, @Nullable TdApi.FormattedText quote, int options) { + public DisplayData (Tdlib tdlib, TdApi.Message message, @Nullable TdApi.InputTextQuote quote, int options) { this.tdlib = tdlib; this.message = message; this.quote = quote; @@ -174,7 +174,7 @@ public boolean isLinkPreviewShowSmallMedia () { return linkPreview != null && linkPreview.hasMedia() && !linkPreview.getOutputShowLargeMedia(); } - public boolean equalsTo (TdApi.Message message, @Nullable TdApi.FormattedText quote, @Options int options, @Nullable LinkPreview linkPreview) { + public boolean equalsTo (TdApi.Message message, @Nullable TdApi.InputTextQuote quote, @Options int options, @Nullable LinkPreview linkPreview) { return this.message == message && Td.equalsTo(this.quote, quote) && this.options == options && this.linkPreview == linkPreview; } @@ -243,7 +243,7 @@ public void setMessage (@Nullable TdApi.Message message, @Nullable TdApi.SearchM setMessage(message, null, filter, forcedTitle, options); } - public void setMessage (@Nullable TdApi.Message message, @Nullable TdApi.FormattedText quote, @Nullable TdApi.SearchMessagesFilter filter, @Nullable String forcedTitle, @Options int options) { + public void setMessage (@Nullable TdApi.Message message, @Nullable TdApi.InputTextQuote quote, @Nullable TdApi.SearchMessagesFilter filter, @Nullable String forcedTitle, @Options int options) { if (message != null) { DisplayData displayData = new DisplayData(tdlib, message, quote, options); displayData.setPreviewFilter(filter); @@ -360,7 +360,7 @@ private void buildPreview () { throw new IllegalStateException(); } if (!Td.isEmpty(data.quote)) { - this.contentPreview = new ContentPreview(data.quote, false); + this.contentPreview = new ContentPreview(data.quote.text, false); } else { this.contentPreview = ContentPreview.getChatListPreview(tdlib, data.message.chatId, data.messageDeleted ? null : data.message, true); } diff --git a/app/src/main/java/org/thunderdog/challegram/component/chat/PinnedMessagesBar.java b/app/src/main/java/org/thunderdog/challegram/component/chat/PinnedMessagesBar.java index 0ccb88d895..50f99f885a 100644 --- a/app/src/main/java/org/thunderdog/challegram/component/chat/PinnedMessagesBar.java +++ b/app/src/main/java/org/thunderdog/challegram/component/chat/PinnedMessagesBar.java @@ -435,7 +435,7 @@ protected void setMessagePreview (ListItem item, int position, MessagePreviewVie }); } else if (data.isMessage()) { TdApi.Message message = data.message; - TdApi.FormattedText quote = data.quote; + TdApi.InputTextQuote quote = data.quote; previewView.setMessage(message, quote, new TdApi.SearchMessagesFilterPinned(), item.getStringValue(), ignoreAlbums ? MessagePreviewView.Options.IGNORE_ALBUM_REFRESHERS : MessagePreviewView.Options.NONE); if (messageList == null) { // override message preview @@ -560,7 +560,7 @@ private void setFocusIndex (int focusIndex) { } public interface MessageListener { - void onMessageClick (PinnedMessagesBar view, TdApi.Message message, @Nullable TdApi.FormattedText quote); + void onMessageClick (PinnedMessagesBar view, TdApi.Message message, @Nullable TdApi.InputTextQuote quote); default void onSelectLinkPreviewUrl (PinnedMessagesBar view, MessagesController.MessageInputContext messageContext, String url) { } default boolean onToggleLargeMedia (PinnedMessagesBar view, MessagePreviewView previewView, MessagesController.MessageInputContext messageContext, LinkPreview linkPreview) { return false; @@ -626,13 +626,13 @@ public static class Entry implements Destroyable { public final Tdlib tdlib; public final TdApi.Message message; - public final @Nullable TdApi.FormattedText quote; + public final @Nullable TdApi.InputTextQuote quote; public final TdlibAccentColor accentColor; public final MessagesController.MessageInputContext linkPreviewContext; public final String linkPreviewUrl; - public Entry (Tdlib tdlib, TdApi.Message message, @Nullable TdApi.FormattedText quote) { + public Entry (Tdlib tdlib, TdApi.Message message, @Nullable TdApi.InputTextQuote quote) { this.tdlib = tdlib; this.message = message; this.linkPreviewContext = null; @@ -777,7 +777,7 @@ public void setStaticMessageList (@Nullable List entries, int scrollToPos } } - public void setMessage (@Nullable Tdlib tdlib, @Nullable TdApi.Message message, @Nullable TdApi.FormattedText quote) { + public void setMessage (@Nullable Tdlib tdlib, @Nullable TdApi.Message message, @Nullable TdApi.InputTextQuote quote) { if (tdlib != null && message != null) { setStaticMessageList(Collections.singletonList(new Entry(tdlib, message, quote)), RecyclerView.NO_POSITION); } else { diff --git a/app/src/main/java/org/thunderdog/challegram/component/chat/ReplyBarView.java b/app/src/main/java/org/thunderdog/challegram/component/chat/ReplyBarView.java index 2dac8a4d4b..587a64d447 100644 --- a/app/src/main/java/org/thunderdog/challegram/component/chat/ReplyBarView.java +++ b/app/src/main/java/org/thunderdog/challegram/component/chat/ReplyBarView.java @@ -120,7 +120,7 @@ public boolean onToggleLargeMedia (PinnedMessagesBar view, MessagePreviewView pr } @Override - public void onMessageClick (PinnedMessagesBar view, TdApi.Message message, @Nullable TdApi.FormattedText quote) { + public void onMessageClick (PinnedMessagesBar view, TdApi.Message message, @Nullable TdApi.InputTextQuote quote) { if (callback != null) { callback.onMessageHighlightRequested(ReplyBarView.this, message, quote); } @@ -249,7 +249,7 @@ public void showWebPage (@NonNull MessagesController.MessageInputContext context setMessageInputContext(context); } - public void setReplyTo (TdApi.Message msg, @Nullable TdApi.FormattedText quote) { + public void setReplyTo (TdApi.Message msg, @Nullable TdApi.InputTextQuote quote) { pinnedMessagesBar.setMessage(tdlib, msg, quote); setLinkPreviewToggleVisible(false); setMessageInputContext(null); @@ -281,7 +281,7 @@ public LinkPreviewToggleView getLinkPreviewToggleView () { public interface Callback { void onDismissReplyBar (ReplyBarView view); - void onMessageHighlightRequested (ReplyBarView view, TdApi.Message message, @Nullable TdApi.FormattedText quote); + void onMessageHighlightRequested (ReplyBarView view, TdApi.Message message, @Nullable TdApi.InputTextQuote quote); void onSelectLinkPreviewUrl (ReplyBarView view, MessagesController.MessageInputContext messageContext, String url); boolean onRequestToggleShowAbove (ReplyBarView view, View buttonView, MessagesController.MessageInputContext messageContext); boolean onRequestToggleLargeMedia (ReplyBarView view, View buttonView, MessagesController.MessageInputContext messageContext, LinkPreview linkPreview); diff --git a/app/src/main/java/org/thunderdog/challegram/component/chat/ReplyComponent.java b/app/src/main/java/org/thunderdog/challegram/component/chat/ReplyComponent.java index 3d3eb4abc6..7dcf59437e 100644 --- a/app/src/main/java/org/thunderdog/challegram/component/chat/ReplyComponent.java +++ b/app/src/main/java/org/thunderdog/challegram/component/chat/ReplyComponent.java @@ -549,7 +549,7 @@ public void set (String title, ContentPreview content, TdApi.Minithumbnail miniT private @Nullable TdApi.Function retryFunction; private boolean ignoreFailures; - private @Nullable TdApi.FormattedText quote; + private @Nullable TdApi.TextQuote quote; private Drawable cornerDrawable; public void load () { @@ -563,7 +563,7 @@ public void load () { switch (message.replyTo.getConstructor()) { case TdApi.MessageReplyToMessage.CONSTRUCTOR: { TdApi.MessageReplyToMessage replyToMessage = (TdApi.MessageReplyToMessage) message.replyTo; - if (replyToMessage.isQuoteManual) { + if (!Td.isEmpty(replyToMessage.quote) && replyToMessage.quote.isManual) { cornerDrawable = Drawables.load(R.drawable.baseline_format_quote_close_18); } else { cornerDrawable = null; @@ -580,12 +580,12 @@ public void load () { } if (!Td.isEmpty(replyToMessage.quote) || replyToMessage.content != null) { this.quote = replyToMessage.quote; - TdApi.Message fakeMessage = TD.newFakeMessage(replyToMessage.chatId, sender, replyToMessage.content == null ? new TdApi.MessageText(replyToMessage.quote, null, null) : replyToMessage.content); + TdApi.Message fakeMessage = TD.newFakeMessage(replyToMessage.chatId, sender, replyToMessage.content == null ? new TdApi.MessageText(replyToMessage.quote.text, null, null) : replyToMessage.content); fakeMessage.id = replyToMessage.messageId; ContentPreview contentPreview = ContentPreview.getChatListPreview(tdlib, fakeMessage.chatId, fakeMessage, true); if (!Td.isEmpty(replyToMessage.quote)) { - contentPreview = new ContentPreview(contentPreview, replyToMessage.quote); + contentPreview = new ContentPreview(contentPreview, replyToMessage.quote.text); } MediaPreview mediaPreview = replyToMessage.content != null ? newMediaPreview(replyToMessage.chatId, replyToMessage.content) : null; this.content = new ContentPreview(translatedText, contentPreview); @@ -862,7 +862,7 @@ private void setMessage (TdApi.Message msg, boolean forceRequestImage, boolean f MediaPreview mediaPreview = newMediaPreview(msg.chatId, msg.content); ContentPreview contentPreview = ContentPreview.getChatListPreview(tdlib, msg.chatId, msg, true); if (!Td.isEmpty(quote)) { - contentPreview = new ContentPreview(contentPreview, quote); + contentPreview = new ContentPreview(contentPreview, quote.text); } if (msg.forwardInfo != null /*&& (parent != null && parent.getMessage().forwardInfo != null)*/) { handleOrigin(msg.forwardInfo.origin); diff --git a/app/src/main/java/org/thunderdog/challegram/core/Lang.java b/app/src/main/java/org/thunderdog/challegram/core/Lang.java index 97796c859a..38aa0b8843 100644 --- a/app/src/main/java/org/thunderdog/challegram/core/Lang.java +++ b/app/src/main/java/org/thunderdog/challegram/core/Lang.java @@ -1069,6 +1069,7 @@ public static String getPinnedMessageText (Tdlib tdlib, TdApi.MessageSender send case TdApi.MessageGiftedPremium.CONSTRUCTOR: case TdApi.MessagePremiumGiftCode.CONSTRUCTOR: case TdApi.MessagePremiumGiveawayCreated.CONSTRUCTOR: + case TdApi.MessagePremiumGiveawayCompleted.CONSTRUCTOR: case TdApi.MessagePremiumGiveaway.CONSTRUCTOR: case TdApi.MessageBasicGroupChatCreate.CONSTRUCTOR: case TdApi.MessageCall.CONSTRUCTOR: @@ -1111,7 +1112,7 @@ public static String getPinnedMessageText (Tdlib tdlib, TdApi.MessageSender send case TdApi.MessageWebAppDataSent.CONSTRUCTOR: break; default: - Td.assertMessageContent_ea2cfacf(); + Td.assertMessageContent_afad899a(); throw Td.unsupported(message.content); } String format = Lang.getString(res); diff --git a/app/src/main/java/org/thunderdog/challegram/data/ContentPreview.java b/app/src/main/java/org/thunderdog/challegram/data/ContentPreview.java index 17cd34b3ee..4334062925 100644 --- a/app/src/main/java/org/thunderdog/challegram/data/ContentPreview.java +++ b/app/src/main/java/org/thunderdog/challegram/data/ContentPreview.java @@ -554,6 +554,12 @@ public ContentPreview runBuilder (TdApi.Message updatedMessage) { } return new ContentPreview(EMOJI_GIFT, 0, text, true); } + case TdApi.MessagePremiumGiveawayCompleted.CONSTRUCTOR: { + TdApi.MessagePremiumGiveawayCompleted giveawayCompleted = (TdApi.MessagePremiumGiveawayCompleted) message.content; + arg1 = giveawayCompleted.winnerCount; + arg2 = giveawayCompleted.unclaimedPrizeCount; + break; + } case TdApi.MessageCustomServiceAction.CONSTRUCTOR: { TdApi.MessageCustomServiceAction serviceAction = (TdApi.MessageCustomServiceAction) message.content; @@ -634,7 +640,7 @@ public ContentPreview runBuilder (TdApi.Message updatedMessage) { case TdApi.MessagePaymentSuccessfulBot.CONSTRUCTOR: case TdApi.MessageWebAppDataReceived.CONSTRUCTOR: default: - Td.assertMessageContent_ea2cfacf(); + Td.assertMessageContent_afad899a(); throw Td.unsupported(message.content); } Refresher refresher = null; @@ -1233,6 +1239,8 @@ else if (isChatsList) case TdApi.MessagePremiumGiveawayCreated.CONSTRUCTOR: return new ContentPreview(EMOJI_GIFT, R.string.BoostingGiveawayJustStarted); + case TdApi.MessagePremiumGiveawayCompleted.CONSTRUCTOR: + return new ContentPreview(EMOJI_GIFT, 0, Lang.plural(R.string.BoostingGiveawayServiceWinnersSelected, arg1), true); case TdApi.MessagePremiumGiveaway.CONSTRUCTOR: { int winnerCount = arg1; @@ -1288,7 +1296,7 @@ else if (isChatsList) case TdApi.MessagePaymentSuccessfulBot.CONSTRUCTOR: case TdApi.MessageWebAppDataReceived.CONSTRUCTOR: default: - Td.assertMessageContent_ea2cfacf(); + Td.assertMessageContent_afad899a(); throw new UnsupportedOperationException(Integer.toString(type)); } } diff --git a/app/src/main/java/org/thunderdog/challegram/data/TD.java b/app/src/main/java/org/thunderdog/challegram/data/TD.java index 701ddbba5a..cc4fe72d55 100644 --- a/app/src/main/java/org/thunderdog/challegram/data/TD.java +++ b/app/src/main/java/org/thunderdog/challegram/data/TD.java @@ -1050,11 +1050,12 @@ public static boolean canSendToSecretChat (TdApi.MessageContent content) { case TdApi.MessageDice.CONSTRUCTOR: case TdApi.MessagePremiumGiveaway.CONSTRUCTOR: case TdApi.MessagePremiumGiftCode.CONSTRUCTOR: - case TdApi.MessagePremiumGiveawayCreated.CONSTRUCTOR: { + case TdApi.MessagePremiumGiveawayCreated.CONSTRUCTOR: + case TdApi.MessagePremiumGiveawayCompleted.CONSTRUCTOR: { return false; } default: { - Td.assertMessageContent_ea2cfacf(); + Td.assertMessageContent_afad899a(); } } return true; @@ -1954,8 +1955,8 @@ public static TdApi.User newFakeUser (long userId, String firstName, String last "", new TdApi.UserStatusEmpty(), null, - TdlibAccentColor.defaultAccentColorIdForUserId(userId), - 0, + TdlibAccentColor.defaultAccentColorIdForUserId(userId), 0, + 0, 0, null, false, false, @@ -5020,7 +5021,7 @@ public static boolean isScreenshotSensitive (TdApi.Message message) { case TdApi.MessageExpiredVideo.CONSTRUCTOR: return true; default: - Td.assertMessageContent_ea2cfacf(); + Td.assertMessageContent_afad899a(); break; } return false; diff --git a/app/src/main/java/org/thunderdog/challegram/data/TGMessage.java b/app/src/main/java/org/thunderdog/challegram/data/TGMessage.java index 1a384ca36c..acac48f224 100644 --- a/app/src/main/java/org/thunderdog/challegram/data/TGMessage.java +++ b/app/src/main/java/org/thunderdog/challegram/data/TGMessage.java @@ -1397,13 +1397,14 @@ private boolean needAvatar () { if (isSponsoredMessage()) { switch (sponsoredMessage.sponsor.type.getConstructor()) { case TdApi.MessageSponsorTypeWebsite.CONSTRUCTOR: + case TdApi.MessageSponsorTypeWebApp.CONSTRUCTOR: case TdApi.MessageSponsorTypePrivateChannel.CONSTRUCTOR: return false; case TdApi.MessageSponsorTypeBot.CONSTRUCTOR: case TdApi.MessageSponsorTypePublicChannel.CONSTRUCTOR: return true; default: - Td.assertMessageSponsorType_ce9e3245(); + Td.assertMessageSponsorType_cdabde01(); throw Td.unsupported(sponsoredMessage.sponsor.type); } } @@ -4028,12 +4029,13 @@ public final void requestAvatar (AvatarReceiver receiver, boolean force) { break; } case TdApi.MessageSponsorTypePrivateChannel.CONSTRUCTOR: - case TdApi.MessageSponsorTypeWebsite.CONSTRUCTOR: { + case TdApi.MessageSponsorTypeWebsite.CONSTRUCTOR: + case TdApi.MessageSponsorTypeWebApp.CONSTRUCTOR: { receiver.requestPlaceholder(tdlib, sender.getPlaceholderMetadata(), AvatarReceiver.Options.NONE); break; } default: - Td.assertMessageSponsorType_ce9e3245(); + Td.assertMessageSponsorType_cdabde01(); throw Td.unsupported(sponsor.type); } } @@ -8008,6 +8010,9 @@ public static TGMessage valueOf (MessagesManager context, TdApi.Message msg, TdA case TdApi.MessagePremiumGiveawayCreated.CONSTRUCTOR: { return new TGMessageService(context, msg, (TdApi.MessagePremiumGiveawayCreated) content); } + case TdApi.MessagePremiumGiveawayCompleted.CONSTRUCTOR: { + return new TGMessageService(context, msg, (TdApi.MessagePremiumGiveawayCompleted) content); + } case TdApi.MessagePremiumGiveaway.CONSTRUCTOR: { if (BuildConfig.DEBUG) { // uncomment once finished @@ -8035,7 +8040,7 @@ public static TGMessage valueOf (MessagesManager context, TdApi.Message msg, TdA break; } default: { - Td.assertMessageContent_ea2cfacf(); + Td.assertMessageContent_afad899a(); throw Td.unsupported(msg.content); } } @@ -9243,6 +9248,11 @@ public void openSponsoredMessage () { tdlib.ui().openInternalLinkType(this, null, bot.link, openParameters, after); break; } + case TdApi.MessageSponsorTypeWebApp.CONSTRUCTOR: { + TdApi.MessageSponsorTypeWebApp webApp = (TdApi.MessageSponsorTypeWebApp) sponsor.type; + tdlib.ui().openInternalLinkType(this, null, webApp.link, openParameters, after); + break; + } case TdApi.MessageSponsorTypePublicChannel.CONSTRUCTOR: { TdApi.MessageSponsorTypePublicChannel publicChannel = (TdApi.MessageSponsorTypePublicChannel) sponsor.type; if (publicChannel.link != null) { @@ -9265,7 +9275,7 @@ public void openSponsoredMessage () { break; } default: - Td.assertMessageSponsorType_ce9e3245(); + Td.assertMessageSponsorType_cdabde01(); throw Td.unsupported(sponsor.type); } } @@ -9290,8 +9300,11 @@ public void openSponsoredMessage () { case TdApi.MessageSponsorTypeWebsite.CONSTRUCTOR: { return R.string.AdOpenWebsite; } + case TdApi.MessageSponsorTypeWebApp.CONSTRUCTOR: { + return R.string.AdOpenApp; + } default: - Td.assertMessageSponsorType_ce9e3245(); + Td.assertMessageSponsorType_cdabde01(); throw Td.unsupported(sponsor.type); } } @@ -9316,6 +9329,11 @@ public String getSponsoredMessageUrl () { // Ignoring other types break; } + case TdApi.MessageSponsorTypeWebApp.CONSTRUCTOR: { + TdApi.MessageSponsorTypeWebApp webApp = (TdApi.MessageSponsorTypeWebApp) sponsor.type; + // No need in URL + break; + } case TdApi.MessageSponsorTypePrivateChannel.CONSTRUCTOR: { TdApi.MessageSponsorTypePrivateChannel privateChannel = (TdApi.MessageSponsorTypePrivateChannel) sponsor.type; return privateChannel.inviteLink; @@ -9335,7 +9353,7 @@ public String getSponsoredMessageUrl () { return website.url; } default: - Td.assertMessageSponsorType_ce9e3245(); + Td.assertMessageSponsorType_cdabde01(); throw Td.unsupported(sponsor.type); } diff --git a/app/src/main/java/org/thunderdog/challegram/data/TGMessageService.java b/app/src/main/java/org/thunderdog/challegram/data/TGMessageService.java index dd794c59aa..1bac4abd19 100644 --- a/app/src/main/java/org/thunderdog/challegram/data/TGMessageService.java +++ b/app/src/main/java/org/thunderdog/challegram/data/TGMessageService.java @@ -119,6 +119,16 @@ public TGMessageService (MessagesManager context, TdApi.Message msg, TdApi.Messa }); } + public TGMessageService (MessagesManager context, TdApi.Message msg, TdApi.MessagePremiumGiveawayCompleted giveawayCompleted) { + super(context, msg); + setTextCreator(() -> { + return getPlural( + R.string.BoostingGiveawayServiceWinnersSelected, + giveawayCompleted.winnerCount + ); + }); + } + public TGMessageService (MessagesManager context, TdApi.Message msg, TdApi.MessageChatSetTheme setTheme) { super(context, msg); setTextCreator(() -> { @@ -320,6 +330,7 @@ public FormattedText createText () { case TdApi.MessageGiftedPremium.CONSTRUCTOR: case TdApi.MessagePremiumGiftCode.CONSTRUCTOR: case TdApi.MessagePremiumGiveawayCreated.CONSTRUCTOR: + case TdApi.MessagePremiumGiveawayCompleted.CONSTRUCTOR: case TdApi.MessagePremiumGiveaway.CONSTRUCTOR: case TdApi.MessageInviteVideoChatParticipants.CONSTRUCTOR: case TdApi.MessagePassportDataReceived.CONSTRUCTOR: @@ -347,7 +358,7 @@ public FormattedText createText () { staticResId = R.string.ActionPinnedNoText; break; default: - Td.assertMessageContent_ea2cfacf(); + Td.assertMessageContent_afad899a(); throw Td.unsupported(message.content); } String format = Lang.getString(staticResId); diff --git a/app/src/main/java/org/thunderdog/challegram/telegram/ChatListener.java b/app/src/main/java/org/thunderdog/challegram/telegram/ChatListener.java index 85800ecddf..3ba9e858b0 100644 --- a/app/src/main/java/org/thunderdog/challegram/telegram/ChatListener.java +++ b/app/src/main/java/org/thunderdog/challegram/telegram/ChatListener.java @@ -43,6 +43,7 @@ default void onChatOnlineMemberCountChanged (long chatId, int onlineMemberCount) default void onChatMessageTtlSettingChanged (long chatId, int messageTtlSetting) { } default void onChatActiveStoriesChanged (@NonNull TdApi.ChatActiveStories activeStories) { } default void onChatVideoChatChanged (long chatId, TdApi.VideoChat videoChat) { } + default void onChatViewAsTopics (long chatId, boolean viewAsTopics) { } default void onChatPendingJoinRequestsChanged (long chatId, TdApi.ChatJoinRequestsInfo pendingJoinRequests) { } default void onChatReplyMarkupChanged (long chatId, long replyMarkupMessageId) { } default void onChatDraftMessageChanged (long chatId, @Nullable TdApi.DraftMessage draftMessage) { } diff --git a/app/src/main/java/org/thunderdog/challegram/telegram/Tdlib.java b/app/src/main/java/org/thunderdog/challegram/telegram/Tdlib.java index ac79619e33..7a7bab813f 100644 --- a/app/src/main/java/org/thunderdog/challegram/telegram/Tdlib.java +++ b/app/src/main/java/org/thunderdog/challegram/telegram/Tdlib.java @@ -3691,6 +3691,10 @@ public String sponsorName (TdApi.MessageSponsor sponsor) { TdApi.MessageSponsorTypeBot bot = (TdApi.MessageSponsorTypeBot) sponsor.type; return cache().userName(bot.botUserId); } + case TdApi.MessageSponsorTypeWebApp.CONSTRUCTOR: { + TdApi.MessageSponsorTypeWebApp webApp = (TdApi.MessageSponsorTypeWebApp) sponsor.type; + return webApp.webAppTitle; + } case TdApi.MessageSponsorTypePublicChannel.CONSTRUCTOR: { TdApi.MessageSponsorTypePublicChannel publicChannel = (TdApi.MessageSponsorTypePublicChannel) sponsor.type; return chatTitle(publicChannel.chatId); @@ -3704,7 +3708,7 @@ public String sponsorName (TdApi.MessageSponsor sponsor) { return website.name; } default: - Td.assertMessageSponsorType_ce9e3245(); + Td.assertMessageSponsorType_cdabde01(); throw Td.unsupported(sponsor.type); } } @@ -4725,7 +4729,7 @@ public TdApi.FormattedText getPendingFormattedText (long chatId, long messageId) case TdApi.MessageAnimatedEmoji.CONSTRUCTOR: return Td.textOrCaption(messageText); } - Td.assertMessageContent_ea2cfacf(); + Td.assertMessageContent_afad899a(); throw Td.unsupported(messageText); } return getPendingMessageCaption(chatId, messageId); @@ -8187,6 +8191,18 @@ private void updateForumTopicInfo (TdApi.UpdateForumTopicInfo update) { listeners.updateForumTopicInfo(update); } + @TdlibThread + private void updateChatViewAsTopics (TdApi.UpdateChatViewAsTopics update) { + synchronized (dataLock) { + final TdApi.Chat chat = chats.get(update.chatId); + if (TdlibUtils.assertChat(update.chatId, chat, update)) { + return; + } + chat.viewAsTopics = update.viewAsTopics; + } + listeners.updateChatViewAsTopics(update); + } + @TdlibThread private void updateChatPendingJoinRequests (TdApi.UpdateChatPendingJoinRequests update) { synchronized (dataLock) { @@ -8964,6 +8980,11 @@ public int getUnreadBadgeCount () { return getUnreadBadge().getCount(); } + @TdlibThread + private void updateSpeechRecognitionTrial (TdApi.UpdateSpeechRecognitionTrial update) { + // TODO + } + @TdlibThread private void updateOption (ClientHolder context, TdApi.UpdateOption update) { final String name = update.name; @@ -9316,6 +9337,22 @@ public TdlibAccentColor accentColorForString (String any) { return accentColor(MathUtils.pickNumber(TdlibAccentColor.BUILT_IN_COLOR_COUNT, any)); } + private int[] availableProfileAccentColorIds; + private final SparseArrayCompat profileAccentColors = new SparseArrayCompat<>(); + + @TdlibThread + private void updateProfileAccentColors (TdApi.UpdateProfileAccentColors update) { + boolean listChanged; + synchronized (profileAccentColors) { + listChanged = Arrays.equals(this.availableProfileAccentColorIds, update.availableAccentColorIds); + this.availableProfileAccentColorIds = update.availableAccentColorIds; + for (TdApi.ProfileAccentColor profileAccentColor : update.colors) { + profileAccentColors.put(profileAccentColor.id, profileAccentColor); + } + } + listeners.updateProfileAccentColors(update, listChanged); + } + // Updates: MEDIA private void updateAnimationSearchParameters (TdApi.UpdateAnimationSearchParameters update) { @@ -9630,6 +9667,10 @@ private void processUpdate (ClientHolder context, TdApi.Update update) { updateForumTopicInfo((TdApi.UpdateForumTopicInfo) update); break; } + case TdApi.UpdateChatViewAsTopics.CONSTRUCTOR: { + updateChatViewAsTopics((TdApi.UpdateChatViewAsTopics) update); + break; + } // Join requests case TdApi.UpdateChatPendingJoinRequests.CONSTRUCTOR: { @@ -9906,6 +9947,10 @@ private void processUpdate (ClientHolder context, TdApi.Update update) { updateOption(context, (TdApi.UpdateOption) update); break; } + case TdApi.UpdateSpeechRecognitionTrial.CONSTRUCTOR: { + updateSpeechRecognitionTrial((TdApi.UpdateSpeechRecognitionTrial) update); + break; + } case TdApi.UpdateSelectedBackground.CONSTRUCTOR: { // TODO? break; @@ -9917,6 +9962,10 @@ private void processUpdate (ClientHolder context, TdApi.Update update) { updateAccentColors((TdApi.UpdateAccentColors) update); break; } + case TdApi.UpdateProfileAccentColors.CONSTRUCTOR: { + updateProfileAccentColors((TdApi.UpdateProfileAccentColors) update); + break; + } // Media case TdApi.UpdateAnimationSearchParameters.CONSTRUCTOR: { @@ -10016,7 +10065,7 @@ private void processUpdate (ClientHolder context, TdApi.Update update) { throw Td.unsupported(update); } default: { - Td.assertUpdate_7e467106(); + Td.assertUpdate_3098a407(); throw Td.unsupported(update); } } @@ -10933,6 +10982,7 @@ public CharSequence getRestrictionText (TdApi.Chat chat, TdApi.Message message) case TdApi.MessageGiftedPremium.CONSTRUCTOR: case TdApi.MessagePremiumGiftCode.CONSTRUCTOR: case TdApi.MessagePremiumGiveawayCreated.CONSTRUCTOR: + case TdApi.MessagePremiumGiveawayCompleted.CONSTRUCTOR: case TdApi.MessagePremiumGiveaway.CONSTRUCTOR: case TdApi.MessageInviteVideoChatParticipants.CONSTRUCTOR: case TdApi.MessagePassportDataReceived.CONSTRUCTOR: @@ -10952,7 +11002,7 @@ public CharSequence getRestrictionText (TdApi.Chat chat, TdApi.Message message) // assuming we want to check RightId.SEND_BASIC_MESSAGES return getBasicMessageRestrictionText(chat); default: - Td.assertMessageContent_ea2cfacf(); + Td.assertMessageContent_afad899a(); throw Td.unsupported(message.content); } } diff --git a/app/src/main/java/org/thunderdog/challegram/telegram/TdlibListeners.java b/app/src/main/java/org/thunderdog/challegram/telegram/TdlibListeners.java index 49fa7784dc..a2d6989279 100644 --- a/app/src/main/java/org/thunderdog/challegram/telegram/TdlibListeners.java +++ b/app/src/main/java/org/thunderdog/challegram/telegram/TdlibListeners.java @@ -1404,48 +1404,37 @@ void updateStoryStealthMode (TdApi.UpdateStoryStealthMode update) { // updateChatVoiceChat - private static void updateChatVideoChat (long chatId, TdApi.VideoChat voiceChat, @Nullable Iterator list) { - if (list != null) { - while (list.hasNext()) { - list.next().onChatVideoChatChanged(chatId, voiceChat); - } - } - } - void updateChatVideoChat (TdApi.UpdateChatVideoChat update) { - updateChatVideoChat(update.chatId, update.videoChat, chatListeners.iterator()); - updateChatVideoChat(update.chatId, update.videoChat, specificChatListeners.iterator(update.chatId)); + runChatUpdate(update.chatId, listener -> { + listener.onChatVideoChatChanged(update.chatId, update.videoChat); + }); } // updateForumTopicInfo void updateForumTopicInfo (TdApi.UpdateForumTopicInfo update) { - updateForumTopicInfo(update.chatId, update.info, chatListeners.iterator()); - updateForumTopicInfo(update.chatId, update.info, specificChatListeners.iterator(update.chatId)); - updateForumTopicInfo(update.chatId, update.info, specificForumTopicListeners.iterator(update.chatId + "_" + update.info.messageThreadId)); + runChatUpdate(update.chatId, listener -> { + listener.onForumTopicInfoChanged(update.chatId, update.info); + }); + runUpdate(specificForumTopicListeners.iterator(update.chatId + "_" + update.info.messageThreadId), listener -> { + listener.onForumTopicInfoChanged(update.chatId, update.info); + }); } - private static void updateForumTopicInfo (long chatId, TdApi.ForumTopicInfo info, @Nullable Iterator list) { - if (list != null) { - while (list.hasNext()) { - list.next().onForumTopicInfoChanged(chatId, info); - } - } + // updateChatViewAsTopics + + void updateChatViewAsTopics (TdApi.UpdateChatViewAsTopics update) { + runChatUpdate(update.chatId, listener -> { + listener.onChatViewAsTopics(update.chatId, update.viewAsTopics); + }); } // updateChatPendingJoinRequests - private static void updateChatPendingJoinRequests (long chatId, TdApi.ChatJoinRequestsInfo pendingJoinRequests, @Nullable Iterator list) { - if (list != null) { - while (list.hasNext()) { - list.next().onChatPendingJoinRequestsChanged(chatId, pendingJoinRequests); - } - } - } - void updateChatPendingJoinRequests (TdApi.UpdateChatPendingJoinRequests update) { - updateChatPendingJoinRequests(update.chatId, update.pendingJoinRequests, chatListeners.iterator()); - updateChatPendingJoinRequests(update.chatId, update.pendingJoinRequests, specificChatListeners.iterator(update.chatId)); + runChatUpdate(update.chatId, listener -> { + listener.onChatPendingJoinRequestsChanged(update.chatId, update.pendingJoinRequests); + }); } // updateUsersNearby @@ -1464,17 +1453,10 @@ void updateUsersNearby (TdApi.UpdateUsersNearby update) { // updateChatIsMarkedAsUnread - private static void updateChatIsMarkedAsUnread (long chatId, boolean isMarkedAsUnread, @Nullable Iterator list) { - if (list != null) { - while (list.hasNext()) { - list.next().onChatMarkedAsUnread(chatId, isMarkedAsUnread); - } - } - } - void updateChatIsMarkedAsUnread (TdApi.UpdateChatIsMarkedAsUnread update) { - updateChatIsMarkedAsUnread(update.chatId, update.isMarkedAsUnread, chatListeners.iterator()); - updateChatIsMarkedAsUnread(update.chatId, update.isMarkedAsUnread, specificChatListeners.iterator(update.chatId)); + runChatUpdate(update.chatId, listener -> { + listener.onChatMarkedAsUnread(update.chatId, update.isMarkedAsUnread); + }); } // updateChatBackground @@ -1503,17 +1485,10 @@ void updateChatBackgroundCustomEmoji (TdApi.UpdateChatBackgroundCustomEmoji upda // updateChatIsTranslatable - private static void updateChatIsTranslatable (long chatId, boolean isTranslatable, @Nullable Iterator list) { - if (list != null) { - while (list.hasNext()) { - list.next().onChatIsTranslatableChanged(chatId, isTranslatable); - } - } - } - void updateChatIsTranslatable (TdApi.UpdateChatIsTranslatable update) { - updateChatIsTranslatable(update.chatId, update.isTranslatable, chatListeners.iterator()); - updateChatIsTranslatable(update.chatId, update.isTranslatable, specificChatListeners.iterator(update.chatId)); + runChatUpdate(update.chatId, listener -> { + listener.onChatIsTranslatableChanged(update.chatId, update.isTranslatable); + }); } // updateChatIsBlocked @@ -1527,23 +1502,17 @@ private static void updateChatBlockList (long chatId, @Nullable TdApi.BlockList } void updateChatBlockList (TdApi.UpdateChatBlockList update) { - updateChatBlockList(update.chatId, update.blockList, chatListeners.iterator()); - updateChatBlockList(update.chatId, update.blockList, specificChatListeners.iterator(update.chatId)); + runChatUpdate(update.chatId, listener -> { + listener.onChatBlockListChanged(update.chatId, update.blockList); + }); } // updateChatClientDataChanged - private static void updateChatClientDataChanged (long chatId, String clientData, @Nullable Iterator list) { - if (list != null) { - while (list.hasNext()) { - list.next().onChatClientDataChanged(chatId, clientData); - } - } - } - void updateChatClientDataChanged (long chatId, String newClientData) { - updateChatClientDataChanged(chatId, newClientData, chatListeners.iterator()); - updateChatClientDataChanged(chatId, newClientData, specificChatListeners.iterator(chatId)); + runChatUpdate(chatId, listener -> { + listener.onChatClientDataChanged(chatId, newClientData); + }); } // updateNotificationSettings @@ -1862,6 +1831,12 @@ void updateAccentColors (TdApi.UpdateAccentColors update) { } } + void updateProfileAccentColors (TdApi.UpdateProfileAccentColors update, boolean listChanged) { + for (TdlibOptionListener listener : optionListeners) { + listener.onProfileAccentColorsChanged(listChanged); + } + } + void updateSuggestedActions (TdApi.UpdateSuggestedActions update) { for (TdlibOptionListener listener : optionListeners) { listener.onSuggestedActionsChanged(update.addedActions, update.removedActions); diff --git a/app/src/main/java/org/thunderdog/challegram/telegram/TdlibOptionListener.java b/app/src/main/java/org/thunderdog/challegram/telegram/TdlibOptionListener.java index a7d0997d29..f0ef0d1966 100644 --- a/app/src/main/java/org/thunderdog/challegram/telegram/TdlibOptionListener.java +++ b/app/src/main/java/org/thunderdog/challegram/telegram/TdlibOptionListener.java @@ -24,4 +24,5 @@ default void onContactRegisteredNotificationsDisabled (boolean areDisabled) { } default void onSuggestedActionsChanged (TdApi.SuggestedAction[] addedActions, TdApi.SuggestedAction[] removedActions) { } default void onArchiveAndMuteChatsFromUnknownUsersEnabled (boolean enabled) { } default void onAccentColorsChanged () { } + default void onProfileAccentColorsChanged (boolean listChanged) { } } diff --git a/app/src/main/java/org/thunderdog/challegram/telegram/TdlibSender.java b/app/src/main/java/org/thunderdog/challegram/telegram/TdlibSender.java index 29b100de4e..02cdb76228 100644 --- a/app/src/main/java/org/thunderdog/challegram/telegram/TdlibSender.java +++ b/app/src/main/java/org/thunderdog/challegram/telegram/TdlibSender.java @@ -121,10 +121,11 @@ public TdlibSender (Tdlib tdlib, long inChatId, TdApi.MessageSponsor sponsor) { break; case TdApi.MessageSponsorTypePrivateChannel.CONSTRUCTOR: case TdApi.MessageSponsorTypeWebsite.CONSTRUCTOR: + case TdApi.MessageSponsorTypeWebApp.CONSTRUCTOR: sender = null; break; default: - Td.assertMessageSponsorType_ce9e3245(); + Td.assertMessageSponsorType_cdabde01(); throw Td.unsupported(sponsor.type); } if (sender != null) { diff --git a/app/src/main/java/org/thunderdog/challegram/telegram/TdlibUi.java b/app/src/main/java/org/thunderdog/challegram/telegram/TdlibUi.java index e058bfea96..3f5372cec9 100644 --- a/app/src/main/java/org/thunderdog/challegram/telegram/TdlibUi.java +++ b/app/src/main/java/org/thunderdog/challegram/telegram/TdlibUi.java @@ -2475,7 +2475,7 @@ public void openMessage (final TdlibDelegate context, final TdApi.MessageLinkInf if (message != null && message.replyTo == null && message.forwardInfo != null && tdlib.isChannelAutoForward(message)) { tdlib.send(new TdApi.GetRepliedMessage(message.forwardInfo.fromChatId, message.forwardInfo.fromMessageId), (repliedMessage, repliedMessageError) -> { if (repliedMessage != null) { - message.replyTo = new TdApi.MessageReplyToMessage(repliedMessage.chatId, repliedMessage.id, null, false, null, repliedMessage.date, repliedMessage.content); + message.replyTo = new TdApi.MessageReplyToMessage(repliedMessage.chatId, repliedMessage.id, null, null, repliedMessage.date, repliedMessage.content); } openMessage(context, messageThread.getChatId(), messageId, messageThread, openParameters); }); diff --git a/app/src/main/java/org/thunderdog/challegram/ui/ChatStatisticsController.java b/app/src/main/java/org/thunderdog/challegram/ui/ChatStatisticsController.java index 02afc1ba9a..d7391d02c3 100644 --- a/app/src/main/java/org/thunderdog/challegram/ui/ChatStatisticsController.java +++ b/app/src/main/java/org/thunderdog/challegram/ui/ChatStatisticsController.java @@ -419,13 +419,13 @@ private void setStatistics (TdApi.ChatStatisticsChannel statistics) { items.add(new ListItem(ListItem.TYPE_VALUED_SETTING_COMPACT, R.id.btn_members, 0, R.string.StatsMembers, false).setData(statistics.memberCount)); items.add(new ListItem(ListItem.TYPE_SEPARATOR_FULL)); items.add(new ListItem(ListItem.TYPE_VALUED_SETTING_COMPACT, R.id.btn_notifications, 0, R.string.StatsNotifications, false).setDoubleValue(statistics.enabledNotificationsPercentage)); - if (!Td.isEmpty(statistics.meanViewCount)) { + if (!Td.isEmpty(statistics.meanMessageViewCount)) { items.add(new ListItem(ListItem.TYPE_SEPARATOR_FULL)); - items.add(new ListItem(ListItem.TYPE_VALUED_SETTING_COMPACT, R.id.btn_view, 0, R.string.StatsViews, false).setData(statistics.meanViewCount)); + items.add(new ListItem(ListItem.TYPE_VALUED_SETTING_COMPACT, R.id.btn_view, 0, R.string.StatsViews, false).setData(statistics.meanMessageViewCount)); } - if (!Td.isEmpty(statistics.meanShareCount)) { + if (!Td.isEmpty(statistics.meanMessageShareCount)) { items.add(new ListItem(ListItem.TYPE_SEPARATOR_FULL)); - items.add(new ListItem(ListItem.TYPE_VALUED_SETTING_COMPACT, R.id.btn_share, 0, R.string.StatsShares, false).setData(statistics.meanShareCount)); + items.add(new ListItem(ListItem.TYPE_VALUED_SETTING_COMPACT, R.id.btn_share, 0, R.string.StatsShares, false).setData(statistics.meanMessageShareCount)); } items.add(new ListItem(ListItem.TYPE_SHADOW_BOTTOM)); items.add(new ListItem(ListItem.TYPE_DESCRIPTION, 0, 0, Lang.getStringBold(R.string.StatsRange, Lang.getDateRange(statistics.period.startDate, statistics.period.endDate, TimeUnit.SECONDS, true)), false)); @@ -447,15 +447,20 @@ private void setStatistics (TdApi.ChatStatisticsChannel statistics) { ); setCharts(items, charts, () -> { - if (statistics.recentMessageInteractions.length > 0) { - setRecentMessageInteractions(statistics.period, statistics.recentMessageInteractions, R.string.StatsRecentPosts); + TdApi.ChatStatisticsInteractionInfo[] recentMessageInteractions = ArrayUtils.filter( + Arrays.asList(statistics.recentInteractions), + item -> item.objectType.getConstructor() == TdApi.ChatStatisticsObjectTypeMessage.CONSTRUCTOR + ).toArray(new TdApi.ChatStatisticsInteractionInfo[0]); + // TODO: stories + if (recentMessageInteractions.length > 0) { + setRecentMessageInteractions(statistics.period, recentMessageInteractions, R.string.StatsRecentPosts); } else { executeScheduledAnimation(); } }); } - private void setRecentMessageInteractions (TdApi.DateRange range, TdApi.ChatStatisticsMessageInteractionInfo[] interactions, @StringRes int header) { + private void setRecentMessageInteractions (TdApi.DateRange range, TdApi.ChatStatisticsInteractionInfo[] interactions, @StringRes int header) { loadInteractionMessages(interactions, () -> { int currentSize = adapter.getItems().size(); adapter.getItems().add(new ListItem(ListItem.TYPE_CHART_HEADER_DETACHED).setData(new MiniChart(header, range))); @@ -472,16 +477,20 @@ private void setRecentMessageInteractions (TdApi.DateRange range, TdApi.ChatStat }); } - private void loadInteractionMessages (TdApi.ChatStatisticsMessageInteractionInfo[] interactions, Runnable onMessagesLoaded) { + private void loadInteractionMessages (TdApi.ChatStatisticsInteractionInfo[] interactions, Runnable onMessagesLoaded) { AtomicInteger remaining = new AtomicInteger(interactions.length); - Tdlib.ResultHandler handler = (message, error) -> { + Runnable after = () -> { + if (remaining.decrementAndGet() == 0) { + runOnUiThreadOptional(onMessagesLoaded); + } + }; + Tdlib.ResultHandler messageHandler = (message, error) -> { if (message != null) { if (message.mediaAlbumId != 0) { if (!interactionMessageAlbums.containsKey(message.mediaAlbumId)) { interactionMessageAlbums.put(message.mediaAlbumId, new ArrayList<>()); } - interactionMessageAlbums.get(message.mediaAlbumId).add(message); } @@ -496,13 +505,26 @@ private void loadInteractionMessages (TdApi.ChatStatisticsMessageInteractionInfo } } - if (remaining.decrementAndGet() == 0) { - runOnUiThreadOptional(onMessagesLoaded); - } + after.run(); }; - for (TdApi.ChatStatisticsMessageInteractionInfo interaction : interactions) { - tdlib.send(new TdApi.GetMessageLocally(getArgumentsStrict().chatId, interaction.messageId), handler); + for (TdApi.ChatStatisticsInteractionInfo interaction : interactions) { + switch (interaction.objectType.getConstructor()) { + case TdApi.ChatStatisticsObjectTypeMessage.CONSTRUCTOR: { + TdApi.ChatStatisticsObjectTypeMessage objectType = (TdApi.ChatStatisticsObjectTypeMessage) interaction.objectType; + tdlib.send(new TdApi.GetMessageLocally(getArgumentsStrict().chatId, objectType.messageId), messageHandler); + break; + } + case TdApi.ChatStatisticsObjectTypeStory.CONSTRUCTOR: { + TdApi.ChatStatisticsObjectTypeStory objectType = (TdApi.ChatStatisticsObjectTypeStory) interaction.objectType; + // TODO: stories + after.run(); + break; + } + default: + Td.assertChatStatisticsObjectType_5cb871fe(); + throw Td.unsupported(interaction.objectType); + } } } @@ -574,9 +596,9 @@ public boolean needAsynchronousAnimation () { public static class MessageInteractionInfoContainer { public final TdApi.Message message; - public final TdApi.ChatStatisticsMessageInteractionInfo messageInteractionInfo; + public final TdApi.ChatStatisticsInteractionInfo messageInteractionInfo; - public MessageInteractionInfoContainer (TdApi.Message message, TdApi.ChatStatisticsMessageInteractionInfo messageInteractionInfo) { + public MessageInteractionInfoContainer (TdApi.Message message, TdApi.ChatStatisticsInteractionInfo messageInteractionInfo) { this.message = message; this.messageInteractionInfo = messageInteractionInfo; } diff --git a/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java b/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java index 8adeebbc2d..f34970c012 100644 --- a/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java +++ b/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java @@ -816,7 +816,7 @@ protected void onViewportChanged () { pinnedMessagesBar.initialize(this); pinnedMessagesBar.setMessageListener(new PinnedMessagesBar.MessageListener() { @Override - public void onMessageClick (PinnedMessagesBar view, TdApi.Message message, TdApi.FormattedText quote) { + public void onMessageClick (PinnedMessagesBar view, TdApi.Message message, TdApi.InputTextQuote quote) { highlightMessage(new MessageId(message.chatId, message.id)); } @@ -6059,9 +6059,9 @@ public void highlightMessage (MessageId messageId, long[] returnToMessageIds) { private static class ReplyInfo { public final Tdlib tdlib; public final TdApi.Message message; - public final @Nullable TdApi.FormattedText quote; + public final @Nullable TdApi.InputTextQuote quote; - public ReplyInfo (Tdlib tdlib, TdApi.Message message, @Nullable TdApi.FormattedText quote) { + public ReplyInfo (Tdlib tdlib, TdApi.Message message, @Nullable TdApi.InputTextQuote quote) { this.tdlib = tdlib; this.message = message; this.quote = quote; @@ -6126,7 +6126,7 @@ public void removeReply (long chatId, long[] messageIds) { } } - public void showReply (TdApi.Message msg, @Nullable TdApi.FormattedText quote, boolean byUser, boolean showKeyboard) { + public void showReply (TdApi.Message msg, @Nullable TdApi.InputTextQuote quote, boolean byUser, boolean showKeyboard) { if (inPreviewMode || isInForceTouchMode()) { return; } @@ -6192,7 +6192,7 @@ public void onDismissReplyBar (ReplyBarView view) { private TooltipOverlayView.TooltipInfo anotherChatHint; @Override - public void onMessageHighlightRequested (ReplyBarView view, TdApi.Message message, @Nullable TdApi.FormattedText quote) { + public void onMessageHighlightRequested (ReplyBarView view, TdApi.Message message, @Nullable TdApi.InputTextQuote quote) { if (message.chatId == getChatId()) { highlightMessage(new MessageId(message.chatId, message.id)); } else { @@ -6233,7 +6233,7 @@ private void forceDraftReply (final TdApi.InputMessageReplyToMessage replyTo) { }); } - public void forceReply (TdApi.Message message, @Nullable TdApi.FormattedText quote) { + public void forceReply (TdApi.Message message, @Nullable TdApi.InputTextQuote quote) { if (message == null || chat == null || inPreviewMode || isInForceTouchMode()) { clearReply(); return; @@ -6429,7 +6429,7 @@ public boolean hasEditedChanges () { return !Td.equalsTo(oldText, newText); } default: { - Td.assertMessageContent_ea2cfacf(); + Td.assertMessageContent_afad899a(); break; } } @@ -6788,7 +6788,7 @@ private void saveMessage (boolean applyMarkdown) { break; } default: { - Td.assertMessageContent_ea2cfacf(); + Td.assertMessageContent_afad899a(); throw Td.unsupported(editContext.message.content); } } diff --git a/app/src/main/java/org/thunderdog/challegram/ui/StickersTrendingController.java b/app/src/main/java/org/thunderdog/challegram/ui/StickersTrendingController.java index 323b04eabe..f2343b26a3 100644 --- a/app/src/main/java/org/thunderdog/challegram/ui/StickersTrendingController.java +++ b/app/src/main/java/org/thunderdog/challegram/ui/StickersTrendingController.java @@ -42,9 +42,12 @@ import org.thunderdog.challegram.util.CancellableResultHandler; import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import me.vkryl.android.widget.FrameLayoutFix; import me.vkryl.core.StringUtils; +import me.vkryl.core.collection.LongSet; import me.vkryl.core.lambda.CancellableRunnable; public class StickersTrendingController extends ViewController implements StickerSmallView.StickerMovementCallback, Client.ResultHandler, TGStickerObj.DataProvider, StickersListener, TGStickerSetInfo.ViewCallback { @@ -254,23 +257,57 @@ private void loadTrending (int offset, int limit, int cellCount) { if (!loadingTrending) { loadingTrending = true; - TdApi.Function function = StringUtils.isEmpty(searchRequest) ? - new TdApi.GetTrendingStickerSets(getStickerType(), offset, limit): - (offset == 0 ? (isEmoji ? - new TdApi.SearchInstalledStickerSets(getStickerType(), searchRequest, 200): - new TdApi.SearchStickerSets(searchRequest)): null); + TdApi.StickerType stickerType = getStickerType(); + String searchRequest = this.searchRequest; + CancellableResultHandler handler = trendingHandler(offset, cellCount, searchRequest); - if (function != null) { - tdlib.client().send(function, trendingHandler(offset, cellCount, searchRequest)); + if (StringUtils.isEmpty(searchRequest)) { + tdlib.client().send( + new TdApi.GetTrendingStickerSets(stickerType, offset, limit), + handler + ); + return; } + + tdlib.send(new TdApi.SearchInstalledStickerSets(stickerType, searchRequest, 200), (foundInstalledStickerSets, error) -> { + if (handler.isCancelled()) + return; + if (error != null || foundInstalledStickerSets.sets.length == 0) { + tdlib.client().send(new TdApi.SearchStickerSets(stickerType, searchRequest), handler); + return; + } + tdlib.send(new TdApi.SearchStickerSets(stickerType, searchRequest), (foundStickerSets, error1) -> { + if (error1 != null || foundInstalledStickerSets.sets.length == 0) { + handler.onResult(foundInstalledStickerSets); + return; + } + List stickerSets = new ArrayList<>(); + Collections.addAll(stickerSets, foundInstalledStickerSets.sets); + LongSet idsSet = new LongSet(foundInstalledStickerSets.sets.length); + for (TdApi.StickerSetInfo setInfo : foundInstalledStickerSets.sets) { + idsSet.add(setInfo.id); + } + for (TdApi.StickerSetInfo setInfo : foundStickerSets.sets) { + if (!idsSet.has(setInfo.id)) { + stickerSets.add(setInfo); + } + } + TdApi.StickerSets mergedStickerSets = new TdApi.StickerSets( + foundInstalledStickerSets.totalCount + foundStickerSets.totalCount, + stickerSets.toArray(new TdApi.StickerSetInfo[0]) + ); + handler.onResult(mergedStickerSets); + }); + }); } } private TdApi.StickerType getStickerType () { if (isEmoji) { return new TdApi.StickerTypeCustomEmoji(); + } else { + return new TdApi.StickerTypeRegular(); } - return new TdApi.StickerTypeRegular(); } private boolean isNeedIgnoreStickersUpdate (final TdApi.StickerType stickerType) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5921f6766f..1c3c81d13d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1631,6 +1631,7 @@ View Group View Channel View Post + Open App Open Website Open Bot View Bot @@ -4890,6 +4891,8 @@ Channel ID %1$s just started a giveaway of Telegram Premium subscriptions for its followers. + %1$s winner of the giveaway was randomly selected by Telegram and received their gift link in a private message. + %1$s winners of the giveaway were randomly selected by Telegram and received their gift link in a private message. Giveaway diff --git a/tdlib b/tdlib index da2907ad27..5c90370975 160000 --- a/tdlib +++ b/tdlib @@ -1 +1 @@ -Subproject commit da2907ad27490ea6ac06c42f9524f1fc50c24e13 +Subproject commit 5c9037097503a6766e2233fa86aa0a4d95051eef diff --git a/vkryl/td b/vkryl/td index 378300bfde..2cf297d692 160000 --- a/vkryl/td +++ b/vkryl/td @@ -1 +1 @@ -Subproject commit 378300bfde173d3fb875822f342cdf052d561876 +Subproject commit 2cf297d69260f04ad03420032864d47e03f61454 From 35147ea2634aacc14ef1cd4dbb6b779c797ee229 Mon Sep 17 00:00:00 2001 From: Kira Roubin Date: Thu, 7 Dec 2023 02:31:13 +0300 Subject: [PATCH 5/9] Copy button for PeerIDs option (#513) --- .../thunderdog/challegram/ui/ProfileController.java | 4 +++- .../challegram/ui/SettingsController.java | 13 +++++++++---- app/src/main/res/values/ids.xml | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/thunderdog/challegram/ui/ProfileController.java b/app/src/main/java/org/thunderdog/challegram/ui/ProfileController.java index 30f92c10cd..14da506d57 100644 --- a/app/src/main/java/org/thunderdog/challegram/ui/ProfileController.java +++ b/app/src/main/java/org/thunderdog/challegram/ui/ProfileController.java @@ -816,6 +816,8 @@ public boolean onOptionItemPressed (View optionItemView, int id) { if (!StringUtils.isEmpty(username)) { UI.copyText("@" + username, R.string.CopiedUsername); } + } else if (id == R.id.btn_peer_id_copy) { + UI.copyText(Long.toString(getPeerId()), R.string.CopiedPeerId); } else if (id == R.id.btn_copyLink) { String username = getProfileUsername(); if (!StringUtils.isEmpty(username)) { @@ -4593,7 +4595,7 @@ public void onClick (View v) { } else if (viewId == R.id.btn_useExplicitDice) { Settings.instance().setNewSetting(((ListItem) v.getTag()).getLongId(), baseAdapter.toggleView(v)); } else if (viewId == R.id.btn_peer_id) { - UI.copyText(Long.toString(getPeerId()), R.string.CopiedPeerId); + showOptions(Strings.buildCounter(getPeerId()), new int[]{R.id.btn_peer_id_copy}, new String[]{Lang.getString(R.string.Copy)}, null, new int[]{R.drawable.baseline_content_copy_24}); } else if (viewId == R.id.btn_username) { boolean canSetUsername = canSetUsername(); boolean canInviteUsers = chat != null && tdlib.canManageInviteLinks(chat); diff --git a/app/src/main/java/org/thunderdog/challegram/ui/SettingsController.java b/app/src/main/java/org/thunderdog/challegram/ui/SettingsController.java index cd5180cc68..0dec067fbd 100644 --- a/app/src/main/java/org/thunderdog/challegram/ui/SettingsController.java +++ b/app/src/main/java/org/thunderdog/challegram/ui/SettingsController.java @@ -1020,10 +1020,15 @@ public void onClick (View v) { c.setArguments(new EditBioController.Arguments(about != null ? about.text : "", 0)); navigateTo(c); } else if (viewId == R.id.btn_peer_id) { - long myId = tdlib.myUserId(true); - if (myId != 0) { - UI.copyText(Long.toString(myId), R.string.CopiedMyUserId); - } + long selfId = tdlib.myUserId(true); + if (selfId == 0) return; + + showOptions(Strings.buildCounter(selfId), new int[]{R.id.btn_peer_id_copy}, new String[]{Lang.getString(R.string.Copy)}, null, new int[]{R.drawable.baseline_content_copy_24}, (itemView, id) -> { + if (id == R.id.btn_peer_id_copy) { + UI.copyText(Long.toString(selfId), R.string.CopiedMyUserId); + } + return true; + }); } else if (viewId == R.id.btn_languageSettings) { navigateTo(new SettingsLanguageController(context, tdlib)); } else if (viewId == R.id.btn_notificationSettings) { diff --git a/app/src/main/res/values/ids.xml b/app/src/main/res/values/ids.xml index 238dbda969..64adc8e350 100644 --- a/app/src/main/res/values/ids.xml +++ b/app/src/main/res/values/ids.xml @@ -364,6 +364,7 @@ + From 420abf2f6f2b690918b1cf5460af792ca1918a6a Mon Sep 17 00:00:00 2001 From: Andrea Mennillo Date: Thu, 7 Dec 2023 00:35:46 +0100 Subject: [PATCH 6/9] Restore clipboard toasts for MIUI based on Android 13 (#512) * add poco and redmi as alternative Xiaomi manufacturers * Restore clipboard toasts for MIUI based on Android 13 * Update app/src/main/java/org/thunderdog/challegram/config/Device.java --------- Co-authored-by: Vyacheslav <6242627+vkryl@users.noreply.github.com> --- .../main/java/org/thunderdog/challegram/config/Device.java | 5 +++++ .../main/java/org/thunderdog/challegram/tool/UIHandler.java | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/thunderdog/challegram/config/Device.java b/app/src/main/java/org/thunderdog/challegram/config/Device.java index 7789080de4..2f295cdd36 100644 --- a/app/src/main/java/org/thunderdog/challegram/config/Device.java +++ b/app/src/main/java/org/thunderdog/challegram/config/Device.java @@ -85,6 +85,8 @@ private static int parseManufacturer (String manufacturer, String brand) { case "nvidia": return NVIDIA; case "xiaomi": + case "poco": + case "redmi": return XIAOMI; case "zte": return ZTE; @@ -187,4 +189,7 @@ private static int parseProduct (int manufacturer, String product) { public static final boolean ROUND_NOTIFICAITON_IMAGE = true; //MANUFACTURER != XIAOMI; public static final boolean FLYME = !StringUtils.isEmpty(Build.DISPLAY) && Build.DISPLAY.toLowerCase().contains("flyme"); + + // Android >= 13 has builtin clipboard toasts, but MIUI based on Android 13 ships without them + public static final boolean HAS_BUILTIN_CLIPBOARD_TOASTS = IS_XIAOMI ? Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU : Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU; } diff --git a/app/src/main/java/org/thunderdog/challegram/tool/UIHandler.java b/app/src/main/java/org/thunderdog/challegram/tool/UIHandler.java index bb4273f058..28aed93672 100644 --- a/app/src/main/java/org/thunderdog/challegram/tool/UIHandler.java +++ b/app/src/main/java/org/thunderdog/challegram/tool/UIHandler.java @@ -15,7 +15,6 @@ package org.thunderdog.challegram.tool; import android.content.Context; -import android.os.Build; import android.os.Handler; import android.os.Message; import android.view.Gravity; @@ -30,6 +29,7 @@ import org.thunderdog.challegram.MainActivity; import org.thunderdog.challegram.R; import org.thunderdog.challegram.U; +import org.thunderdog.challegram.config.Device; import org.thunderdog.challegram.core.Lang; import org.thunderdog.challegram.data.TGAudio; import org.thunderdog.challegram.navigation.NavigationController; @@ -358,7 +358,7 @@ public void handleMessage (Message msg) { case COPY_TEXT: { try { U.copyText((CharSequence) msg.obj); - if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.S_V2 && msg.arg1 != 0) { + if (!Device.HAS_BUILTIN_CLIPBOARD_TOASTS && msg.arg1 != 0) { showCustomToast(msg.arg1, Toast.LENGTH_SHORT, 0); } } catch (Throwable t) { From efbbd3ac7d183548de3144e05ec33ef1fbabd57c Mon Sep 17 00:00:00 2001 From: vkryl <6242627+vkryl@users.noreply.github.com> Date: Thu, 7 Dec 2023 08:37:45 +0900 Subject: [PATCH 7/9] Use `Long.toString` for Peer IDs in pop-ups --- .../java/org/thunderdog/challegram/ui/ProfileController.java | 2 +- .../java/org/thunderdog/challegram/ui/SettingsController.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/thunderdog/challegram/ui/ProfileController.java b/app/src/main/java/org/thunderdog/challegram/ui/ProfileController.java index 14da506d57..df4671c7c1 100644 --- a/app/src/main/java/org/thunderdog/challegram/ui/ProfileController.java +++ b/app/src/main/java/org/thunderdog/challegram/ui/ProfileController.java @@ -4595,7 +4595,7 @@ public void onClick (View v) { } else if (viewId == R.id.btn_useExplicitDice) { Settings.instance().setNewSetting(((ListItem) v.getTag()).getLongId(), baseAdapter.toggleView(v)); } else if (viewId == R.id.btn_peer_id) { - showOptions(Strings.buildCounter(getPeerId()), new int[]{R.id.btn_peer_id_copy}, new String[]{Lang.getString(R.string.Copy)}, null, new int[]{R.drawable.baseline_content_copy_24}); + showOptions(Long.toString(getPeerId()), new int[]{R.id.btn_peer_id_copy}, new String[]{Lang.getString(R.string.Copy)}, null, new int[]{R.drawable.baseline_content_copy_24}); } else if (viewId == R.id.btn_username) { boolean canSetUsername = canSetUsername(); boolean canInviteUsers = chat != null && tdlib.canManageInviteLinks(chat); diff --git a/app/src/main/java/org/thunderdog/challegram/ui/SettingsController.java b/app/src/main/java/org/thunderdog/challegram/ui/SettingsController.java index 0dec067fbd..03cf707965 100644 --- a/app/src/main/java/org/thunderdog/challegram/ui/SettingsController.java +++ b/app/src/main/java/org/thunderdog/challegram/ui/SettingsController.java @@ -92,7 +92,6 @@ import me.vkryl.core.collection.IntList; import me.vkryl.core.lambda.CancellableRunnable; import me.vkryl.core.reference.ReferenceList; -import me.vkryl.td.ChatId; import me.vkryl.td.Td; public class SettingsController extends ViewController implements @@ -1023,7 +1022,7 @@ public void onClick (View v) { long selfId = tdlib.myUserId(true); if (selfId == 0) return; - showOptions(Strings.buildCounter(selfId), new int[]{R.id.btn_peer_id_copy}, new String[]{Lang.getString(R.string.Copy)}, null, new int[]{R.drawable.baseline_content_copy_24}, (itemView, id) -> { + showOptions(Long.toString(selfId), new int[]{R.id.btn_peer_id_copy}, new String[]{Lang.getString(R.string.Copy)}, null, new int[]{R.drawable.baseline_content_copy_24}, (itemView, id) -> { if (id == R.id.btn_peer_id_copy) { UI.copyText(Long.toString(selfId), R.string.CopiedMyUserId); } From d69b6e66ed81f92fc76945fd921694323a022a97 Mon Sep 17 00:00:00 2001 From: vkryl <6242627+vkryl@users.noreply.github.com> Date: Thu, 7 Dec 2023 09:06:39 +0900 Subject: [PATCH 8/9] Fixed displaying quotes in sending messages --- .../challegram/component/chat/ReplyComponent.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/thunderdog/challegram/component/chat/ReplyComponent.java b/app/src/main/java/org/thunderdog/challegram/component/chat/ReplyComponent.java index 7dcf59437e..483ee13e06 100644 --- a/app/src/main/java/org/thunderdog/challegram/component/chat/ReplyComponent.java +++ b/app/src/main/java/org/thunderdog/challegram/component/chat/ReplyComponent.java @@ -571,13 +571,6 @@ public void load () { if (replyToMessage.origin != null) { handleOrigin(replyToMessage.origin); } - if (message.chatId == replyToMessage.chatId) { - TdApi.Message foundMessage = parent.manager().getAdapter().tryFindMessage(replyToMessage.chatId, replyToMessage.messageId); - if (foundMessage != null) { - setMessage(foundMessage, false, true); - return; - } - } if (!Td.isEmpty(replyToMessage.quote) || replyToMessage.content != null) { this.quote = replyToMessage.quote; TdApi.Message fakeMessage = TD.newFakeMessage(replyToMessage.chatId, sender, replyToMessage.content == null ? new TdApi.MessageText(replyToMessage.quote.text, null, null) : replyToMessage.content); @@ -594,6 +587,12 @@ public void load () { buildLayout(); invalidate(mediaPreview != null); this.ignoreFailures = true; + } else if (message.chatId == replyToMessage.chatId) { + TdApi.Message foundMessage = parent.manager().getAdapter().tryFindMessage(replyToMessage.chatId, replyToMessage.messageId); + if (foundMessage != null) { + setMessage(foundMessage, false, true); + return; + } } if (replyToMessage.origin == null) { if (message.forwardInfo != null && message.forwardInfo.fromChatId != 0 && message.forwardInfo.fromMessageId != 0 && !parent.isRepliesChat()) { From fc3ad3a672cc0b39cfc1351eccf744a10c4c5997 Mon Sep 17 00:00:00 2001 From: vkryl <6242627+vkryl@users.noreply.github.com> Date: Thu, 7 Dec 2023 22:42:27 +0900 Subject: [PATCH 9/9] Version bump to `1669` --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 8718c7cc77..94c91da128 100644 --- a/version.properties +++ b/version.properties @@ -1,5 +1,5 @@ # App -version.app=1668 +version.app=1669 version.major=0 # Anchor date point in app versioning version.creation=873642600564