Skip to content

Commit

Permalink
Merge remote-tracking branch 'official/master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao committed Dec 5, 2023
2 parents 41fe8a9 + 33a48d8 commit f99ded6
Show file tree
Hide file tree
Showing 278 changed files with 17,660 additions and 3,918 deletions.
8 changes: 4 additions & 4 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import cn.hutool.core.util.RuntimeUtil
apply plugin: "com.android.application"
apply plugin: "kotlin-android"

def verName = "10.2.9"
def verCode = 1149
def verName = "10.3.2"
def verCode = 1150


def officialVer = "10.2.9"
def officialCode = 4087
def officialVer = "10.3.2"
def officialCode = 4145

def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json")

Expand Down
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 @@ -473,11 +473,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 @@ -535,6 +535,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 @@ -556,7 +560,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 @@ -1128,7 +1134,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 @@ -6049,6 +6055,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
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 @@ -405,20 +405,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 @@ -440,6 +479,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 @@ -1119,25 +1119,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
Loading

0 comments on commit f99ded6

Please sign in to comment.