Skip to content

Commit 33a48d8

Browse files
committed
update to 10.3.2 (4145)
1 parent 220f6b4 commit 33a48d8

File tree

277 files changed

+17621
-3863
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

277 files changed

+17621
-3863
lines changed

TMessagesProj/jni/gifvideo.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,7 @@ extern "C" JNIEXPORT int JNICALL Java_org_telegram_ui_Components_AnimatedFileDra
13391339
}
13401340
}
13411341

1342-
extern "C" JNIEXPORT jint JNICALL Java_org_telegram_ui_Components_AnimatedFileDrawable_getVideoFrame(JNIEnv *env, jclass clazz, jlong ptr, jobject bitmap, jintArray data, jint stride, jboolean preview, jfloat start_time, jfloat end_time) {
1342+
extern "C" JNIEXPORT jint JNICALL Java_org_telegram_ui_Components_AnimatedFileDrawable_getVideoFrame(JNIEnv *env, jclass clazz, jlong ptr, jobject bitmap, jintArray data, jint stride, jboolean preview, jfloat start_time, jfloat end_time, jboolean loop) {
13431343
if (ptr == NULL || bitmap == nullptr) {
13441344
return 0;
13451345
}
@@ -1408,18 +1408,19 @@ extern "C" JNIEXPORT jint JNICALL Java_org_telegram_ui_Components_AnimatedFileDr
14081408
LOGE("can't decode packet flushed %s", info->src);
14091409
return 0;
14101410
}
1411-
if (!preview && got_frame == 0) {
1412-
if (info->has_decoded_frames) {
1413-
int64_t start_from = 0;
1414-
if (start_time > 0) {
1415-
start_from = (int64_t)(start_time / av_q2d(info->video_stream->time_base));
1416-
}
1417-
if ((ret = av_seek_frame(info->fmt_ctx, info->video_stream_idx, start_from, AVSEEK_FLAG_BACKWARD | AVSEEK_FLAG_FRAME)) < 0) {
1418-
LOGE("can't seek to begin of file %s, %s", info->src, av_err2str(ret));
1419-
return 0;
1420-
} else {
1421-
avcodec_flush_buffers(info->video_dec_ctx);
1422-
}
1411+
if (!preview && got_frame == 0 && info->has_decoded_frames) {
1412+
if (!loop) {
1413+
return 0;
1414+
}
1415+
int64_t start_from = 0;
1416+
if (start_time > 0) {
1417+
start_from = (int64_t)(start_time / av_q2d(info->video_stream->time_base));
1418+
}
1419+
if ((ret = av_seek_frame(info->fmt_ctx, info->video_stream_idx, start_from, AVSEEK_FLAG_BACKWARD | AVSEEK_FLAG_FRAME)) < 0) {
1420+
LOGE("can't seek to begin of file %s, %s", info->src, av_err2str(ret));
1421+
return 0;
1422+
} else {
1423+
avcodec_flush_buffers(info->video_dec_ctx);
14231424
}
14241425
}
14251426
}

TMessagesProj/jni/tgnet/ApiScheme.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -518,11 +518,15 @@ void TL_user::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &er
518518
if ((flags2 & 32) != 0) {
519519
stories_max_id = stream->readInt32(&error);
520520
}
521-
if ((flags2 & 128) != 0) {
522-
color = stream->readInt32(&error);
521+
if ((flags2 & 256) != 0) {
522+
int magic = stream->readInt32(&error);
523+
color_color = stream->readInt32(&error);
524+
color_background_emoji_id = stream->readInt64(&error);
523525
}
524-
if ((flags2 & 64) != 0) {
525-
background_emoji_id = stream->readInt64(&error);
526+
if ((flags2 & 512) != 0) {
527+
int magic = stream->readInt32(&error);
528+
profile_color_color = stream->readInt32(&error);
529+
profile_color_background_emoji_id = stream->readInt64(&error);
526530
}
527531
}
528532

@@ -591,11 +595,15 @@ void TL_user::serializeToStream(NativeByteBuffer *stream) {
591595
if ((flags2 & 32) != 0) {
592596
stream->writeInt32(stories_max_id);
593597
}
594-
if ((flags2 & 128) != 0) {
595-
stream->writeInt32(color);
598+
if ((flags2 & 256) != 0) {
599+
stream->writeInt32(0xba278146);
600+
stream->writeInt32(color_color);
601+
stream->writeInt32(color_background_emoji_id);
596602
}
597-
if ((flags2 & 64) != 0) {
598-
stream->writeInt64(background_emoji_id);
603+
if ((flags2 & 512) != 0) {
604+
stream->writeInt32(0xba278146);
605+
stream->writeInt32(profile_color_color);
606+
stream->writeInt32(profile_color_background_emoji_id);
599607
}
600608
}
601609

TMessagesProj/jni/tgnet/ApiScheme.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,10 @@ class User : public TLObject {
339339
int32_t emojiStatusMagic;
340340
int64_t emojiStatusDocumentId;
341341
int32_t emojiStatusUntil;
342-
int32_t color;
343-
int64_t background_emoji_id;
342+
int32_t color_color;
343+
int64_t color_background_emoji_id;
344+
int32_t profile_color_color;
345+
int64_t profile_color_background_emoji_id;
344346

345347
static User *TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error);
346348
};
@@ -357,7 +359,7 @@ class TL_userEmpty : public User {
357359
class TL_user : public User {
358360

359361
public:
360-
static const uint32_t constructor = 0xeb602f25;
362+
static const uint32_t constructor = 0x215c4438;
361363

362364
void readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error);
363365
void serializeToStream(NativeByteBuffer *stream);

TMessagesProj/src/main/java/androidx/recyclerview/widget/ChatListItemAnimator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.telegram.messenger.SharedConfig;
2222
import org.telegram.ui.ActionBar.Theme;
2323
import org.telegram.ui.Cells.BotHelpCell;
24+
import org.telegram.ui.Cells.ChatActionCell;
2425
import org.telegram.ui.Cells.ChatMessageCell;
2526
import org.telegram.ui.ChatActivity;
2627
import org.telegram.ui.Components.ChatGreetingsView;

TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,11 @@ public static Activity findActivity(Context context) {
454454
return null;
455455
}
456456

457-
public static CharSequence premiumText(String str, Runnable runnable) {
457+
public static SpannableStringBuilder premiumText(String str, Runnable runnable) {
458458
return replaceSingleTag(str, -1, REPLACING_TAG_TYPE_LINKBOLD, runnable);
459459
}
460460

461-
public static CharSequence replaceSingleTag(String str, Runnable runnable) {
461+
public static SpannableStringBuilder replaceSingleTag(String str, Runnable runnable) {
462462
return replaceSingleTag(str, -1, 0, runnable);
463463
}
464464

@@ -516,6 +516,10 @@ public void updateDrawState(TextPaint textPaint) {
516516
}
517517

518518
public static SpannableStringBuilder replaceSingleLink(String str, int color) {
519+
return replaceSingleLink(str, color, null);
520+
}
521+
522+
public static SpannableStringBuilder replaceSingleLink(String str, int color, Runnable onClick) {
519523
int startIndex = str.indexOf("**");
520524
int endIndex = str.indexOf("**", startIndex + 1);
521525
str = str.replace("**", "");
@@ -537,7 +541,9 @@ public void updateDrawState(@NonNull TextPaint ds) {
537541

538542
@Override
539543
public void onClick(@NonNull View view) {
540-
544+
if (onClick != null) {
545+
onClick.run();
546+
}
541547
}
542548
}, index, index + len, 0);
543549
}
@@ -1061,7 +1067,7 @@ public static int calcBitmapColor(Bitmap bitmap) {
10611067
public static int[] calcDrawableColor(Drawable drawable) {
10621068
if (drawable instanceof ChatBackgroundDrawable) {
10631069
ChatBackgroundDrawable chatBackgroundDrawable = (ChatBackgroundDrawable) drawable;
1064-
return calcDrawableColor(chatBackgroundDrawable.getDrawable());
1070+
return calcDrawableColor(chatBackgroundDrawable.getDrawable(true));
10651071
}
10661072
int bitmapColor = 0xff000000;
10671073
int[] result = new int[4];
@@ -5461,6 +5467,9 @@ public static void forEachViews(View view, Consumer<View> consumer) {
54615467
}
54625468

54635469
public static void forEachViews(RecyclerView recyclerView, Consumer<View> consumer) {
5470+
if (recyclerView == null) {
5471+
return;
5472+
}
54645473
for (int i = 0; i < recyclerView.getChildCount(); i++) {
54655474
consumer.accept(recyclerView.getChildAt(i));
54665475
}

TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public class BuildVars {
2424
public static boolean USE_CLOUD_STRINGS = true;
2525
public static boolean CHECK_UPDATES = true;
2626
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
27-
public static int BUILD_VERSION = 4087;
28-
public static String BUILD_VERSION_STRING = "10.2.9";
27+
public static int BUILD_VERSION = 4139;
28+
public static String BUILD_VERSION_STRING = "10.3.2";
2929
public static int APP_ID = 4;
3030
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
3131

TMessagesProj/src/main/java/org/telegram/messenger/ChatObject.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,4 +2086,34 @@ private void setAspectRatio(float aspectRatio, Call call) {
20862086
}
20872087
}
20882088
}
2089+
2090+
public static MessagesController.PeerColor getPeerColorForAvatar(int currentAccount, TLRPC.Chat chat) {
2091+
// if (chat != null && chat.profile_color != null && chat.profile_color.color >= 0 && MessagesController.getInstance(currentAccount).profilePeerColors != null) {
2092+
// return MessagesController.getInstance(currentAccount).profilePeerColors.getColor(chat.profile_color.color);
2093+
// }
2094+
return null;
2095+
}
2096+
2097+
public static int getColorId(TLRPC.Chat chat) {
2098+
if (chat == null) return 0;
2099+
if (chat.color != null && (chat.color.flags & 1) != 0) return chat.color.color;
2100+
return (int) (chat.id % 7);
2101+
}
2102+
2103+
public static long getEmojiId(TLRPC.Chat chat) {
2104+
if (chat != null && chat.color != null && (chat.color.flags & 2) != 0) return chat.color.background_emoji_id;
2105+
return 0;
2106+
}
2107+
2108+
public static int getProfileColorId(TLRPC.Chat chat) {
2109+
if (chat == null) return 0;
2110+
// if (chat.profile_color != null && (chat.profile_color.flags & 1) != 0) return chat.profile_color.color;
2111+
return -1;
2112+
}
2113+
2114+
public static long getProfileEmojiId(TLRPC.Chat chat) {
2115+
// if (chat != null && chat.profile_color != null && (chat.profile_color.flags & 2) != 0) return chat.profile_color.background_emoji_id;
2116+
return -1;
2117+
}
2118+
20892119
}

TMessagesProj/src/main/java/org/telegram/messenger/ChatThemeController.java

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -403,20 +403,59 @@ public void clearCache() {
403403
getSharedPreferences().edit().clear().apply();
404404
}
405405

406+
public void processUpdate(TLRPC.TL_updatePeerWallpaper update) {
407+
if (update.peer instanceof TLRPC.TL_peerUser) {
408+
TLRPC.UserFull userFull = getMessagesController().getUserFull(update.peer.user_id);
409+
if (userFull != null) {
410+
if (wallpaperEquals(userFull.wallpaper, update.wallpaper)) {
411+
return;
412+
}
413+
final long dialogId = userFull.id;
414+
userFull.wallpaper_overridden = update.wallpaper_overridden;
415+
userFull.wallpaper = update.wallpaper;
416+
userFull.flags |= 16777216;
417+
getMessagesStorage().updateUserInfo(userFull, false);
418+
saveChatWallpaper(dialogId, null);
419+
AndroidUtilities.runOnUIThread(() -> {
420+
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.userInfoDidLoad, dialogId, userFull);
421+
});
422+
}
423+
} else {
424+
// todo
425+
}
426+
}
427+
428+
public static boolean wallpaperEquals(TLRPC.WallPaper a, TLRPC.WallPaper b) {
429+
if ((a == null || a instanceof TLRPC.TL_wallPaperNoFile) && (b == null || b instanceof TLRPC.TL_wallPaperNoFile)) {
430+
return true;
431+
}
432+
if (a instanceof TLRPC.TL_wallPaper && b instanceof TLRPC.TL_wallPaper) {
433+
return a.id == b.id;
434+
}
435+
return false;
436+
}
437+
406438
public void clearWallpaper(long dialogId, boolean notify) {
439+
clearWallpaper(dialogId, notify, false);
440+
}
441+
442+
public void clearWallpaper(long dialogId, boolean notify, boolean onlyRevert) {
407443
TLRPC.TL_messages_setChatWallPaper req = new TLRPC.TL_messages_setChatWallPaper();
408-
if (dialogId > 0) {
444+
if (dialogId >= 0) {
409445
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(dialogId);
410446
req.peer = MessagesController.getInputPeer(user);
411-
TLRPC.UserFull userFull = getMessagesController().getUserFull(dialogId);
412-
if (userFull != null) {
413-
userFull.wallpaper = null;
414-
userFull.flags &= ~16777216;
415-
getMessagesStorage().updateUserInfo(userFull, false);
416-
}
417-
saveChatWallpaper(dialogId, null);
418-
if (notify) {
419-
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.userInfoDidLoad, dialogId, userFull);
447+
req.revert = onlyRevert;
448+
if (!onlyRevert) {
449+
TLRPC.UserFull userFull = getMessagesController().getUserFull(dialogId);
450+
if (userFull != null) {
451+
userFull.wallpaper = null;
452+
userFull.flags &= ~16777216;
453+
getMessagesStorage().updateUserInfo(userFull, false);
454+
}
455+
saveChatWallpaper(dialogId, null);
456+
if (notify) {
457+
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.userInfoDidLoad, dialogId, userFull);
458+
}
420459
}
421460
} else {
422461
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-dialogId);
@@ -438,6 +477,7 @@ public int setWallpaperToUser(long dialogId, String wallpaperLocalPath, Theme.Ov
438477
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-dialogId);
439478
req.peer = MessagesController.getInputPeer(chat);
440479
}
480+
req.for_both = wallpaperInfo.forBoth;
441481
boolean applyOnRequest = true;
442482
if (serverWallpaper != null && serverWallpaper.messageOwner.action instanceof TLRPC.TL_messageActionSetChatWallPaper) {
443483
applyOnRequest = false;

TMessagesProj/src/main/java/org/telegram/messenger/ChatsWidgetService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ public RemoteViews getViewAt(int position) {
150150
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
151151
}
152152
} else {
153-
avatarDrawable = new AvatarDrawable(chat);
153+
avatarDrawable = new AvatarDrawable();
154+
avatarDrawable.setInfo(accountInstance.getCurrentAccount(), chat);
154155
}
155156
avatarDrawable.setBounds(0, 0, size, size);
156157
avatarDrawable.draw(canvas);

TMessagesProj/src/main/java/org/telegram/messenger/CodeHighlighting.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ private static void matchGrammar(String text, LinkedList tokenList, TokenPattern
420420

421421
StringToken wrapped;
422422
if (pattern.insideTokenPatterns != null) {
423-
wrapped = new StringToken(pattern.group, tokenize(match.string, pattern.insideTokenPatterns, depth + 1), match.length);
423+
wrapped = new StringToken(pattern.group, tokenize(match.string, pattern.insideTokenPatterns, pattern, depth + 1), match.length);
424424
} else if (pattern.insideLanguage != null) {
425425
wrapped = new StringToken(pattern.group, tokenize(match.string, compiledPatterns.get(pattern.insideLanguage), pattern, depth + 1), match.length);
426426
} else {

TMessagesProj/src/main/java/org/telegram/messenger/ContactsWidgetService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ public RemoteViews getViewAt(int position) {
155155
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
156156
}
157157
} else {
158-
avatarDrawable = new AvatarDrawable(chat);
158+
avatarDrawable = new AvatarDrawable();
159+
avatarDrawable.setInfo(accountInstance.getCurrentAccount(), chat);
159160
}
160161
avatarDrawable.setBounds(0, 0, size, size);
161162
avatarDrawable.draw(canvas);

TMessagesProj/src/main/java/org/telegram/messenger/ImageReceiver.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,25 +1113,6 @@ public boolean setBackupImage() {
11131113
return false;
11141114
}
11151115

1116-
private int bufferedFrame;
1117-
public void incrementFrames(int inc) {
1118-
if (currentMediaDrawable instanceof RLottieDrawable) {
1119-
// RLottieDrawable rlottie = (RLottieDrawable) currentMediaDrawable;
1120-
// inc = (int) Math.round((float) rlottie.getFramesCount() / rlottie.getDuration() * (1f / 30f));
1121-
// rlottie.setCurrentFrame(
1122-
// (rlottie.getCurrentFrame() + inc) % (int) rlottie.getFramesCount()
1123-
// );
1124-
} else if (currentMediaDrawable instanceof AnimatedFileDrawable) {
1125-
int lastFrame = (int) bufferedFrame;
1126-
bufferedFrame += inc;
1127-
int currentFrame = (int) bufferedFrame;
1128-
while (lastFrame != currentFrame) {
1129-
((AnimatedFileDrawable) currentMediaDrawable).getNextFrame();
1130-
currentFrame--;
1131-
}
1132-
}
1133-
}
1134-
11351116
public boolean onAttachedToWindow() {
11361117
if (attachedToWindow) {
11371118
return false;

TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,11 @@ public static String formatPluralStringComma(String key, int plural, char symbol
11701170
int resourceId = ApplicationLoader.applicationContext.getResources().getIdentifier(param, "string", ApplicationLoader.applicationContext.getPackageName());
11711171
value = ApplicationLoader.applicationContext.getString(resourceId);
11721172
}
1173+
if (value == null) {
1174+
int resourceId = ApplicationLoader.applicationContext.getResources().getIdentifier(key + "_other", "string", ApplicationLoader.applicationContext.getPackageName());
1175+
value = ApplicationLoader.applicationContext.getString(resourceId);
1176+
}
1177+
value = value.replace("%d", "%1$s");
11731178
value = value.replace("%1$d", "%1$s");
11741179

11751180
if (getInstance().currentLocale != null) {
@@ -1685,6 +1690,42 @@ public static String formatSeenDate(long date) {
16851690
return "LOC_ERR";
16861691
}
16871692

1693+
public static String formatShortDate(long date) {
1694+
try {
1695+
date *= 1000;
1696+
Calendar rightNow = Calendar.getInstance();
1697+
int day = rightNow.get(Calendar.DAY_OF_YEAR);
1698+
int year = rightNow.get(Calendar.YEAR);
1699+
long timeInMillis = rightNow.getTimeInMillis();
1700+
rightNow.setTimeInMillis(date);
1701+
int dateDay = rightNow.get(Calendar.DAY_OF_YEAR);
1702+
int dateYear = rightNow.get(Calendar.YEAR);
1703+
1704+
if (timeInMillis - date < 1000 * 60) {
1705+
return LocaleController.getString(R.string.ShortNow);
1706+
} else if (timeInMillis - date < 1000 * 60 * 60) {
1707+
int minutesAgo = (int) ((timeInMillis - date) / (1000 * 60));
1708+
return LocaleController.formatPluralString("ShortMinutesAgo", minutesAgo);
1709+
} else if (dateDay == day && year == dateYear) {
1710+
if (timeInMillis - date < 12 * 1000 * 60 * 60) {
1711+
int hoursAgo = (int) ((timeInMillis - date) / (1000 * 60 * 60));
1712+
return LocaleController.formatPluralString("ShortHoursAgo", hoursAgo);
1713+
} else {
1714+
return LocaleController.getString(R.string.ShortToday);
1715+
}
1716+
} else if (dateDay + 1 == day && year == dateYear) {
1717+
return LocaleController.getString(R.string.ShortYesterday);
1718+
} else if (Math.abs(System.currentTimeMillis() - date) < 31536000000L) {
1719+
return getInstance().formatterDayMonth.format(new Date(date));
1720+
} else {
1721+
return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().formatterYear.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
1722+
}
1723+
} catch (Exception e) {
1724+
FileLog.e(e);
1725+
}
1726+
return "LOC_ERR";
1727+
}
1728+
16881729
public static String formatStoryDate(long date) {
16891730
try {
16901731
date *= 1000;

0 commit comments

Comments
 (0)