Skip to content

Commit

Permalink
Update to 8.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
xaxtix committed Feb 12, 2022
1 parent 146cea2 commit 3b4919a
Show file tree
Hide file tree
Showing 99 changed files with 1,898 additions and 814 deletions.
4 changes: 2 additions & 2 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ android {
}
}

defaultConfig.versionCode = 2551
defaultConfig.versionCode = 2563

applicationVariants.all { variant ->
variant.outputs.all { output ->
Expand All @@ -319,7 +319,7 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 30
versionName "8.5.1"
versionName "8.5.2"

vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

Expand Down
7 changes: 3 additions & 4 deletions TMessagesProj/jni/gifvideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,9 +1179,9 @@ static inline void writeFrameToBitmap(JNIEnv *env, VideoInfo *info, jintArray da
void *pixels;
if (AndroidBitmap_lockPixels(env, bitmap, &pixels) >= 0) {
if (info->sws_ctx == nullptr) {
if (info->frame->format > AV_PIX_FMT_NONE && info->frame->format < AV_PIX_FMT_NB && !info->frame->format == AV_PIX_FMT_YUVA420P) {
if (info->frame->format > AV_PIX_FMT_NONE && info->frame->format < AV_PIX_FMT_NB && info->frame->format != AV_PIX_FMT_YUVA420P) {
info->sws_ctx = sws_getContext(info->frame->width, info->frame->height, (AVPixelFormat) info->frame->format, bitmapWidth, bitmapHeight, AV_PIX_FMT_RGBA, SWS_BILINEAR, NULL, NULL, NULL);
} else if (info->video_dec_ctx->pix_fmt > AV_PIX_FMT_NONE && info->video_dec_ctx->pix_fmt < AV_PIX_FMT_NB && !info->frame->format == AV_PIX_FMT_YUVA420P) {
} else if (info->video_dec_ctx->pix_fmt > AV_PIX_FMT_NONE && info->video_dec_ctx->pix_fmt < AV_PIX_FMT_NB && info->frame->format != AV_PIX_FMT_YUVA420P) {
info->sws_ctx = sws_getContext(info->video_dec_ctx->width, info->video_dec_ctx->height, info->video_dec_ctx->pix_fmt, bitmapWidth, bitmapHeight, AV_PIX_FMT_RGBA, SWS_BILINEAR, NULL, NULL, NULL);
}
}
Expand All @@ -1203,8 +1203,7 @@ static inline void writeFrameToBitmap(JNIEnv *env, VideoInfo *info, jintArray da
uint8_t __attribute__ ((aligned (16))) *dst_data[1];
dst_data[0] = (uint8_t *) pixels;
info->dst_linesize[0] = stride;
sws_scale(info->sws_ctx, info->frame->data, info->frame->linesize, 0,
info->frame->height, dst_data, info->dst_linesize);
sws_scale(info->sws_ctx, info->frame->data, info->frame->linesize, 0, info->frame->height, dst_data, info->dst_linesize);
}
}
AndroidBitmap_unlockPixels(env, bitmap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ public static void createEmptyFile(File f) {
writer.flush();
writer.close();
} catch (Throwable e) {
FileLog.e(e);
FileLog.e(e, false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public int read(int offset, int readLength) {
}
lastOffset = offset + availableLength;
} catch (Exception e) {
FileLog.e(e);
FileLog.e(e, false);
}
return availableLength;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@
import android.content.pm.ApplicationInfo;
import android.content.res.Configuration;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Handler;
import android.os.PowerManager;
import android.os.SystemClock;
import android.telephony.TelephonyManager;
import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.multidex.MultiDex;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.firebase.messaging.FirebaseMessaging;
Expand All @@ -39,8 +45,6 @@

import java.io.File;

import androidx.multidex.MultiDex;

public class ApplicationLoader extends Application {

@SuppressLint("StaticFieldLeak")
Expand All @@ -50,6 +54,8 @@ public class ApplicationLoader extends Application {

private static ConnectivityManager connectivityManager;
private static volatile boolean applicationInited = false;
private static long lastNetworkCheckTypeTime;
private static int lastKnownNetworkType = -1;

public static long startTime;

Expand Down Expand Up @@ -312,6 +318,20 @@ private static void ensureCurrentNetworkGet(boolean force) {
connectivityManager = (ConnectivityManager) ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
}
currentNetworkInfo = connectivityManager.getActiveNetworkInfo();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
connectivityManager.registerDefaultNetworkCallback(new ConnectivityManager.NetworkCallback() {
@Override
public void onAvailable(@NonNull Network network) {
lastKnownNetworkType = -1;
}

@Override
public void onCapabilitiesChanged(@NonNull Network network, @NonNull NetworkCapabilities networkCapabilities) {
super.onCapabilitiesChanged(network, networkCapabilities);
lastKnownNetworkType = -1;
}
});
}
} catch (Throwable ignore) {

}
Expand Down Expand Up @@ -381,11 +401,16 @@ public static int getAutodownloadNetworkType() {
return StatsController.TYPE_MOBILE;
}
if (currentNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI || currentNetworkInfo.getType() == ConnectivityManager.TYPE_ETHERNET) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && (lastKnownNetworkType == StatsController.TYPE_MOBILE || lastKnownNetworkType == StatsController.TYPE_WIFI) && System.currentTimeMillis() - lastNetworkCheckTypeTime < 5000) {
return lastKnownNetworkType;
}
if (connectivityManager.isActiveNetworkMetered()) {
return StatsController.TYPE_MOBILE;
lastKnownNetworkType = StatsController.TYPE_MOBILE;
} else {
return StatsController.TYPE_WIFI;
lastKnownNetworkType = StatsController.TYPE_WIFI;
}
lastNetworkCheckTypeTime = System.currentTimeMillis();
return lastKnownNetworkType;
}
if (currentNetworkInfo.isRoaming()) {
return StatsController.TYPE_ROAMING;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,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 = 2551;
public static String BUILD_VERSION_STRING = "8.5.1";
public static int BUILD_VERSION = 2563;
public static String BUILD_VERSION_STRING = "8.5.2";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,9 @@ public static String fixFileName(String fileName) {
}

public static String getDocumentFileName(TLRPC.Document document) {
if (document.file_name_fixed != null) {
return document.file_name_fixed;
}
String fileName = null;
if (document != null) {
if (document.file_name != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,7 @@ public void onMessageReceived(RemoteMessage message) {
messageOwner.from_scheduled = scheduled;

MessageObject messageObject = new MessageObject(currentAccount, messageOwner, messageText, name, userName, localMessage, channel, supergroup, edited);
messageObject.isReactionPush = loc_key.startsWith("REACT_") || loc_key.startsWith("CHAT_REACT_");
ArrayList<MessageObject> arrayList = new ArrayList<>();
arrayList.add(messageObject);
canRelease = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.InterruptedIOException;
import java.io.RandomAccessFile;
import java.net.HttpURLConnection;
import java.net.SocketException;
Expand Down Expand Up @@ -534,7 +535,7 @@ protected Boolean doInBackground(Void... voids) {
} else if (e instanceof FileNotFoundException) {
canRetry = false;
sentLogs = false;
} else if (e instanceof InterruptedException) {
} else if (e instanceof InterruptedIOException) {
sentLogs = false;
}
FileLog.e(e, sentLogs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ public void setImage(ImageLocation mediaLocation, String mediaFilter, ImageLocat
currentExt = ext;
currentParentObject = null;
currentCacheType = 0;
roundPaint.setShader(null);
staticThumbDrawable = thumb;
currentAlpha = 1.0f;
previousAlpha = 1f;
Expand Down Expand Up @@ -573,6 +574,7 @@ public void setImage(ImageLocation mediaLocation, String mediaFilter, ImageLocat
mediaShader = null;
legacyShader = null;
legacyCanvas = null;
roundPaint.setShader(null);
if (legacyBitmap != null) {
legacyBitmap.recycle();
legacyBitmap = null;
Expand Down Expand Up @@ -721,6 +723,7 @@ public void setImageBitmap(Drawable bitmap) {
fileDrawable.setAllowDecodeSingleFrame(true);
}
thumbShader = null;
roundPaint.setShader(null);
staticThumbDrawable = bitmap;
updateDrawableRadius(bitmap);
currentMediaLocation = null;
Expand Down Expand Up @@ -865,6 +868,7 @@ public void onDetachedFromWindow() {
if (staticThumbDrawable != null) {
staticThumbDrawable = null;
thumbShader = null;
roundPaint.setShader(null);
}
clearImage();
if (isPressed == 0) {
Expand Down Expand Up @@ -1005,9 +1009,6 @@ private void drawDrawable(Canvas canvas, Drawable drawable, int alpha, BitmapSha
bitmapW = bitmapDrawable.getIntrinsicWidth();
bitmapH = bitmapDrawable.getIntrinsicHeight();
}
if (parentView != null) {
parentView.invalidate();
}
} else {
Bitmap bitmap = bitmapDrawable.getBitmap();
if (bitmap != null && bitmap.isRecycled()) {
Expand Down Expand Up @@ -2408,6 +2409,7 @@ public void startCrossfadeFromStaticThumb(Bitmap thumb) {
currentThumbKey = null;
currentThumbDrawable = null;
thumbShader = null;
roundPaint.setShader(null);
staticThumbDrawable = new BitmapDrawable(null, thumb);
crossfadeWithThumb = true;
currentAlpha = 0f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3694,6 +3694,7 @@ public void start() {
}
if (sourceFile.exists()) {
saveFileInternal(isMusic ? 3 : 2, sourceFile, name);
copiedFiles++;
}
}
} else {
Expand Down Expand Up @@ -3744,6 +3745,7 @@ public void start() {
}
if (sourceFile.exists()) {
copyFile(sourceFile, destFile, message.getMimeType());
copiedFiles++;
}
}
}
Expand Down Expand Up @@ -3863,7 +3865,6 @@ private boolean copyFile(File sourceFile, File destFile, String mime) {
FileLog.e(e);
}
});
copiedFiles++;
return true;
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public class MessageObject {
public long reactionsLastCheckTime;
public String customName;
public boolean reactionsChanged;
public boolean isReactionPush;
private int isRoundVideoCached;
public long eventId;
public int contentType;
Expand Down Expand Up @@ -5057,7 +5058,7 @@ public static boolean isAnimatedStickerDocument(TLRPC.Document document, boolean
}

public static boolean canAutoplayAnimatedSticker(TLRPC.Document document) {
return isAnimatedStickerDocument(document, true) && SharedConfig.getDevicePerformanceClass() != SharedConfig.PERFORMANCE_CLASS_LOW;
return (isAnimatedStickerDocument(document, true) || isVideoStickerDocument(document)) && SharedConfig.getDevicePerformanceClass() != SharedConfig.PERFORMANCE_CLASS_LOW;
}

public static boolean isMaskDocument(TLRPC.Document document) {
Expand Down Expand Up @@ -6318,7 +6319,7 @@ public boolean isReactionsAvailable() {
return !isEditing() && !isSponsored() && isSent() && messageOwner.action == null;
}

public boolean selectReaction(String reaction, boolean fromDoubleTap) {
public boolean selectReaction(String reaction, boolean big, boolean fromDoubleTap) {
if (messageOwner.reactions == null) {
messageOwner.reactions = new TLRPC.TL_messageReactions();
messageOwner.reactions.can_see_list = isFromGroup() || isFromUser();
Expand All @@ -6335,6 +6336,10 @@ public boolean selectReaction(String reaction, boolean fromDoubleTap) {
}
}

if (choosenReaction != null && choosenReaction == newReaction && big) {
return true;
}

if (choosenReaction != null && (choosenReaction == newReaction || fromDoubleTap)) {
choosenReaction.chosen = false;
choosenReaction.count--;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14004,7 +14004,7 @@ public boolean processUpdateArray(ArrayList<TLRPC.Update> updates, ArrayList<TLR
return true;
}

private void checkUnreadReactions(long dialogId, SparseBooleanArray unreadReactions) {
public void checkUnreadReactions(long dialogId, SparseBooleanArray unreadReactions) {
getMessagesStorage().getStorageQueue().postRunnable(() -> {
boolean needReload = false;
boolean changed = false;
Expand Down Expand Up @@ -14071,6 +14071,7 @@ private void checkUnreadReactions(long dialogId, SparseBooleanArray unreadReacti
AndroidUtilities.runOnUIThread(() -> {
TLRPC.Dialog dialog = dialogs_dict.get(dialogId);
if (dialog == null) {
getMessagesStorage().updateDialogUnreadReactions(dialogId, count, false);
return;
}
dialog.unread_reactions_count = count;
Expand All @@ -14084,6 +14085,7 @@ private void checkUnreadReactions(long dialogId, SparseBooleanArray unreadReacti
AndroidUtilities.runOnUIThread(() -> {
TLRPC.Dialog dialog = dialogs_dict.get(dialogId);
if (dialog == null) {
getMessagesStorage().updateDialogUnreadReactions(dialogId, finalNewUnreadCount, true);
return;
}
dialog.unread_reactions_count += finalNewUnreadCount;
Expand Down

0 comments on commit 3b4919a

Please sign in to comment.