Skip to content

Commit

Permalink
update to 10.3.2 (4145)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkaraush committed Dec 4, 2023
1 parent 220f6b4 commit 33a48d8
Show file tree
Hide file tree
Showing 277 changed files with 17,621 additions and 3,863 deletions.
27 changes: 14 additions & 13 deletions TMessagesProj/jni/gifvideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ extern "C" JNIEXPORT int JNICALL Java_org_telegram_ui_Components_AnimatedFileDra
}
}

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) {
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) {
if (ptr == NULL || bitmap == nullptr) {
return 0;
}
Expand Down Expand Up @@ -1408,18 +1408,19 @@ extern "C" JNIEXPORT jint JNICALL Java_org_telegram_ui_Components_AnimatedFileDr
LOGE("can't decode packet flushed %s", info->src);
return 0;
}
if (!preview && got_frame == 0) {
if (info->has_decoded_frames) {
int64_t start_from = 0;
if (start_time > 0) {
start_from = (int64_t)(start_time / av_q2d(info->video_stream->time_base));
}
if ((ret = av_seek_frame(info->fmt_ctx, info->video_stream_idx, start_from, AVSEEK_FLAG_BACKWARD | AVSEEK_FLAG_FRAME)) < 0) {
LOGE("can't seek to begin of file %s, %s", info->src, av_err2str(ret));
return 0;
} else {
avcodec_flush_buffers(info->video_dec_ctx);
}
if (!preview && got_frame == 0 && info->has_decoded_frames) {
if (!loop) {
return 0;
}
int64_t start_from = 0;
if (start_time > 0) {
start_from = (int64_t)(start_time / av_q2d(info->video_stream->time_base));
}
if ((ret = av_seek_frame(info->fmt_ctx, info->video_stream_idx, start_from, AVSEEK_FLAG_BACKWARD | AVSEEK_FLAG_FRAME)) < 0) {
LOGE("can't seek to begin of file %s, %s", info->src, av_err2str(ret));
return 0;
} else {
avcodec_flush_buffers(info->video_dec_ctx);
}
}
}
Expand Down
24 changes: 16 additions & 8 deletions TMessagesProj/jni/tgnet/ApiScheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,15 @@ void TL_user::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &er
if ((flags2 & 32) != 0) {
stories_max_id = stream->readInt32(&error);
}
if ((flags2 & 128) != 0) {
color = stream->readInt32(&error);
if ((flags2 & 256) != 0) {
int magic = stream->readInt32(&error);
color_color = stream->readInt32(&error);
color_background_emoji_id = stream->readInt64(&error);
}
if ((flags2 & 64) != 0) {
background_emoji_id = stream->readInt64(&error);
if ((flags2 & 512) != 0) {
int magic = stream->readInt32(&error);
profile_color_color = stream->readInt32(&error);
profile_color_background_emoji_id = stream->readInt64(&error);
}
}

Expand Down Expand Up @@ -591,11 +595,15 @@ void TL_user::serializeToStream(NativeByteBuffer *stream) {
if ((flags2 & 32) != 0) {
stream->writeInt32(stories_max_id);
}
if ((flags2 & 128) != 0) {
stream->writeInt32(color);
if ((flags2 & 256) != 0) {
stream->writeInt32(0xba278146);
stream->writeInt32(color_color);
stream->writeInt32(color_background_emoji_id);
}
if ((flags2 & 64) != 0) {
stream->writeInt64(background_emoji_id);
if ((flags2 & 512) != 0) {
stream->writeInt32(0xba278146);
stream->writeInt32(profile_color_color);
stream->writeInt32(profile_color_background_emoji_id);
}
}

Expand Down
8 changes: 5 additions & 3 deletions TMessagesProj/jni/tgnet/ApiScheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,10 @@ class User : public TLObject {
int32_t emojiStatusMagic;
int64_t emojiStatusDocumentId;
int32_t emojiStatusUntil;
int32_t color;
int64_t background_emoji_id;
int32_t color_color;
int64_t color_background_emoji_id;
int32_t profile_color_color;
int64_t profile_color_background_emoji_id;

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

public:
static const uint32_t constructor = 0xeb602f25;
static const uint32_t constructor = 0x215c4438;

void readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error);
void serializeToStream(NativeByteBuffer *stream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.telegram.messenger.SharedConfig;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Cells.BotHelpCell;
import org.telegram.ui.Cells.ChatActionCell;
import org.telegram.ui.Cells.ChatMessageCell;
import org.telegram.ui.ChatActivity;
import org.telegram.ui.Components.ChatGreetingsView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,11 @@ public static Activity findActivity(Context context) {
return null;
}

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

public static CharSequence replaceSingleTag(String str, Runnable runnable) {
public static SpannableStringBuilder replaceSingleTag(String str, Runnable runnable) {
return replaceSingleTag(str, -1, 0, runnable);
}

Expand Down Expand Up @@ -516,6 +516,10 @@ public void updateDrawState(TextPaint textPaint) {
}

public static SpannableStringBuilder replaceSingleLink(String str, int color) {
return replaceSingleLink(str, color, null);
}

public static SpannableStringBuilder replaceSingleLink(String str, int color, Runnable onClick) {
int startIndex = str.indexOf("**");
int endIndex = str.indexOf("**", startIndex + 1);
str = str.replace("**", "");
Expand All @@ -537,7 +541,9 @@ public void updateDrawState(@NonNull TextPaint ds) {

@Override
public void onClick(@NonNull View view) {

if (onClick != null) {
onClick.run();
}
}
}, index, index + len, 0);
}
Expand Down Expand Up @@ -1061,7 +1067,7 @@ public static int calcBitmapColor(Bitmap bitmap) {
public static int[] calcDrawableColor(Drawable drawable) {
if (drawable instanceof ChatBackgroundDrawable) {
ChatBackgroundDrawable chatBackgroundDrawable = (ChatBackgroundDrawable) drawable;
return calcDrawableColor(chatBackgroundDrawable.getDrawable());
return calcDrawableColor(chatBackgroundDrawable.getDrawable(true));
}
int bitmapColor = 0xff000000;
int[] result = new int[4];
Expand Down Expand Up @@ -5461,6 +5467,9 @@ public static void forEachViews(View view, Consumer<View> consumer) {
}

public static void forEachViews(RecyclerView recyclerView, Consumer<View> consumer) {
if (recyclerView == null) {
return;
}
for (int i = 0; i < recyclerView.getChildCount(); i++) {
consumer.accept(recyclerView.getChildAt(i));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true;
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
public static int BUILD_VERSION = 4087;
public static String BUILD_VERSION_STRING = "10.2.9";
public static int BUILD_VERSION = 4139;
public static String BUILD_VERSION_STRING = "10.3.2";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

Expand Down
30 changes: 30 additions & 0 deletions TMessagesProj/src/main/java/org/telegram/messenger/ChatObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -2086,4 +2086,34 @@ private void setAspectRatio(float aspectRatio, Call call) {
}
}
}

public static MessagesController.PeerColor getPeerColorForAvatar(int currentAccount, TLRPC.Chat chat) {
// if (chat != null && chat.profile_color != null && chat.profile_color.color >= 0 && MessagesController.getInstance(currentAccount).profilePeerColors != null) {
// return MessagesController.getInstance(currentAccount).profilePeerColors.getColor(chat.profile_color.color);
// }
return null;
}

public static int getColorId(TLRPC.Chat chat) {
if (chat == null) return 0;
if (chat.color != null && (chat.color.flags & 1) != 0) return chat.color.color;
return (int) (chat.id % 7);
}

public static long getEmojiId(TLRPC.Chat chat) {
if (chat != null && chat.color != null && (chat.color.flags & 2) != 0) return chat.color.background_emoji_id;
return 0;
}

public static int getProfileColorId(TLRPC.Chat chat) {
if (chat == null) return 0;
// if (chat.profile_color != null && (chat.profile_color.flags & 1) != 0) return chat.profile_color.color;
return -1;
}

public static long getProfileEmojiId(TLRPC.Chat chat) {
// if (chat != null && chat.profile_color != null && (chat.profile_color.flags & 2) != 0) return chat.profile_color.background_emoji_id;
return -1;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -403,20 +403,59 @@ public void clearCache() {
getSharedPreferences().edit().clear().apply();
}

public void processUpdate(TLRPC.TL_updatePeerWallpaper update) {
if (update.peer instanceof TLRPC.TL_peerUser) {
TLRPC.UserFull userFull = getMessagesController().getUserFull(update.peer.user_id);
if (userFull != null) {
if (wallpaperEquals(userFull.wallpaper, update.wallpaper)) {
return;
}
final long dialogId = userFull.id;
userFull.wallpaper_overridden = update.wallpaper_overridden;
userFull.wallpaper = update.wallpaper;
userFull.flags |= 16777216;
getMessagesStorage().updateUserInfo(userFull, false);
saveChatWallpaper(dialogId, null);
AndroidUtilities.runOnUIThread(() -> {
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.userInfoDidLoad, dialogId, userFull);
});
}
} else {
// todo
}
}

public static boolean wallpaperEquals(TLRPC.WallPaper a, TLRPC.WallPaper b) {
if ((a == null || a instanceof TLRPC.TL_wallPaperNoFile) && (b == null || b instanceof TLRPC.TL_wallPaperNoFile)) {
return true;
}
if (a instanceof TLRPC.TL_wallPaper && b instanceof TLRPC.TL_wallPaper) {
return a.id == b.id;
}
return false;
}

public void clearWallpaper(long dialogId, boolean notify) {
clearWallpaper(dialogId, notify, false);
}

public void clearWallpaper(long dialogId, boolean notify, boolean onlyRevert) {
TLRPC.TL_messages_setChatWallPaper req = new TLRPC.TL_messages_setChatWallPaper();
if (dialogId > 0) {
if (dialogId >= 0) {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(dialogId);
req.peer = MessagesController.getInputPeer(user);
TLRPC.UserFull userFull = getMessagesController().getUserFull(dialogId);
if (userFull != null) {
userFull.wallpaper = null;
userFull.flags &= ~16777216;
getMessagesStorage().updateUserInfo(userFull, false);
}
saveChatWallpaper(dialogId, null);
if (notify) {
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.userInfoDidLoad, dialogId, userFull);
req.revert = onlyRevert;
if (!onlyRevert) {
TLRPC.UserFull userFull = getMessagesController().getUserFull(dialogId);
if (userFull != null) {
userFull.wallpaper = null;
userFull.flags &= ~16777216;
getMessagesStorage().updateUserInfo(userFull, false);
}
saveChatWallpaper(dialogId, null);
if (notify) {
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.userInfoDidLoad, dialogId, userFull);
}
}
} else {
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-dialogId);
Expand All @@ -438,6 +477,7 @@ public int setWallpaperToUser(long dialogId, String wallpaperLocalPath, Theme.Ov
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-dialogId);
req.peer = MessagesController.getInputPeer(chat);
}
req.for_both = wallpaperInfo.forBoth;
boolean applyOnRequest = true;
if (serverWallpaper != null && serverWallpaper.messageOwner.action instanceof TLRPC.TL_messageActionSetChatWallPaper) {
applyOnRequest = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ public RemoteViews getViewAt(int position) {
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
}
} else {
avatarDrawable = new AvatarDrawable(chat);
avatarDrawable = new AvatarDrawable();
avatarDrawable.setInfo(accountInstance.getCurrentAccount(), chat);
}
avatarDrawable.setBounds(0, 0, size, size);
avatarDrawable.draw(canvas);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ private static void matchGrammar(String text, LinkedList tokenList, TokenPattern

StringToken wrapped;
if (pattern.insideTokenPatterns != null) {
wrapped = new StringToken(pattern.group, tokenize(match.string, pattern.insideTokenPatterns, depth + 1), match.length);
wrapped = new StringToken(pattern.group, tokenize(match.string, pattern.insideTokenPatterns, pattern, depth + 1), match.length);
} else if (pattern.insideLanguage != null) {
wrapped = new StringToken(pattern.group, tokenize(match.string, compiledPatterns.get(pattern.insideLanguage), pattern, depth + 1), match.length);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ public RemoteViews getViewAt(int position) {
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
}
} else {
avatarDrawable = new AvatarDrawable(chat);
avatarDrawable = new AvatarDrawable();
avatarDrawable.setInfo(accountInstance.getCurrentAccount(), chat);
}
avatarDrawable.setBounds(0, 0, size, size);
avatarDrawable.draw(canvas);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1113,25 +1113,6 @@ public boolean setBackupImage() {
return false;
}

private int bufferedFrame;
public void incrementFrames(int inc) {
if (currentMediaDrawable instanceof RLottieDrawable) {
// RLottieDrawable rlottie = (RLottieDrawable) currentMediaDrawable;
// inc = (int) Math.round((float) rlottie.getFramesCount() / rlottie.getDuration() * (1f / 30f));
// rlottie.setCurrentFrame(
// (rlottie.getCurrentFrame() + inc) % (int) rlottie.getFramesCount()
// );
} else if (currentMediaDrawable instanceof AnimatedFileDrawable) {
int lastFrame = (int) bufferedFrame;
bufferedFrame += inc;
int currentFrame = (int) bufferedFrame;
while (lastFrame != currentFrame) {
((AnimatedFileDrawable) currentMediaDrawable).getNextFrame();
currentFrame--;
}
}
}

public boolean onAttachedToWindow() {
if (attachedToWindow) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,11 @@ public static String formatPluralStringComma(String key, int plural, char symbol
int resourceId = ApplicationLoader.applicationContext.getResources().getIdentifier(param, "string", ApplicationLoader.applicationContext.getPackageName());
value = ApplicationLoader.applicationContext.getString(resourceId);
}
if (value == null) {
int resourceId = ApplicationLoader.applicationContext.getResources().getIdentifier(key + "_other", "string", ApplicationLoader.applicationContext.getPackageName());
value = ApplicationLoader.applicationContext.getString(resourceId);
}
value = value.replace("%d", "%1$s");
value = value.replace("%1$d", "%1$s");

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

public static String formatShortDate(long date) {
try {
date *= 1000;
Calendar rightNow = Calendar.getInstance();
int day = rightNow.get(Calendar.DAY_OF_YEAR);
int year = rightNow.get(Calendar.YEAR);
long timeInMillis = rightNow.getTimeInMillis();
rightNow.setTimeInMillis(date);
int dateDay = rightNow.get(Calendar.DAY_OF_YEAR);
int dateYear = rightNow.get(Calendar.YEAR);

if (timeInMillis - date < 1000 * 60) {
return LocaleController.getString(R.string.ShortNow);
} else if (timeInMillis - date < 1000 * 60 * 60) {
int minutesAgo = (int) ((timeInMillis - date) / (1000 * 60));
return LocaleController.formatPluralString("ShortMinutesAgo", minutesAgo);
} else if (dateDay == day && year == dateYear) {
if (timeInMillis - date < 12 * 1000 * 60 * 60) {
int hoursAgo = (int) ((timeInMillis - date) / (1000 * 60 * 60));
return LocaleController.formatPluralString("ShortHoursAgo", hoursAgo);
} else {
return LocaleController.getString(R.string.ShortToday);
}
} else if (dateDay + 1 == day && year == dateYear) {
return LocaleController.getString(R.string.ShortYesterday);
} else if (Math.abs(System.currentTimeMillis() - date) < 31536000000L) {
return getInstance().formatterDayMonth.format(new Date(date));
} else {
return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().formatterYear.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
}
} catch (Exception e) {
FileLog.e(e);
}
return "LOC_ERR";
}

public static String formatStoryDate(long date) {
try {
date *= 1000;
Expand Down
Loading

0 comments on commit 33a48d8

Please sign in to comment.