Skip to content

Commit

Permalink
feat: Update to 1669
Browse files Browse the repository at this point in the history
  • Loading branch information
jplie committed Dec 7, 2023
2 parents ba8d9de + fc3ad3a commit 96d34b5
Show file tree
Hide file tree
Showing 30 changed files with 314 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public static MediaPreview valueOf (Tdlib tdlib, TdApi.Message message, @Nullabl
break;
}
default: {
Td.assertMessageContent_ea2cfacf();
Td.assertMessageContent_afad899a();
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ 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;
public boolean messageDeleted;
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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -777,7 +777,7 @@ public void setStaticMessageList (@Nullable List<Entry> 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,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 () {
Expand All @@ -571,29 +571,22 @@ 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;
}
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, 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);
Expand All @@ -602,6 +595,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()) {
Expand Down Expand Up @@ -870,7 +869,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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
3 changes: 2 additions & 1 deletion app/src/main/java/org/thunderdog/challegram/core/Lang.java
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
}
Expand Down
11 changes: 6 additions & 5 deletions app/src/main/java/org/thunderdog/challegram/data/TD.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 96d34b5

Please sign in to comment.