Skip to content

Commit

Permalink
Update to 5.13.0 (1823)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrKLO committed Jan 2, 2020
1 parent 4e55e97 commit 12caa1e
Show file tree
Hide file tree
Showing 20 changed files with 181 additions and 95 deletions.
2 changes: 1 addition & 1 deletion TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ android {
}
}

defaultConfig.versionCode = 1821
defaultConfig.versionCode = 1823

applicationVariants.all { variant ->
variant.outputs.all { output ->
Expand Down
4 changes: 2 additions & 2 deletions TMessagesProj/jni/tgnet/ConnectionsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,7 @@ void ConnectionsManager::processServerResponse(TLObject *message, int64_t messag
int64_t time = (int64_t) (messageId / 4294967296.0 * 1000);
int64_t currentTime = getCurrentTimeMillis();
timeDifference = (int32_t) ((time - currentTime) / 1000 - currentPingTime / 2);
lastOutgoingMessageId = messageId > (lastOutgoingMessageId ? messageId : lastOutgoingMessageId);
lastOutgoingMessageId = (messageId > lastOutgoingMessageId ? messageId : lastOutgoingMessageId);
}
if ((connection->getConnectionType() & ConnectionTypeDownload) == 0 || !datacenter->containsServerSalt(messageSalt, media)) {
TL_bad_server_salt *response = (TL_bad_server_salt *) message;
Expand Down Expand Up @@ -2186,7 +2186,7 @@ void ConnectionsManager::processRequestQueue(uint32_t connectionTypes, uint32_t

bool forceThisRequest = (connectionTypes & requestConnectionType) && requestDatacenter->getDatacenterId() == dc;

if (typeInfo == typeid(TL_get_future_salts) || typeInfo == typeid(TL_destroy_session)) {
if (typeInfo == typeid(TL_get_future_salts)) {
if (request->messageId != 0) {
request->addRespondMessageId(request->messageId);
}
Expand Down
3 changes: 2 additions & 1 deletion TMessagesProj/jni/tgnet/Datacenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,8 @@ void Datacenter::mergeServerSalts(TL_future_salts *futureSalts, bool media) {
std::vector<std::unique_ptr<TL_future_salt>> &salts = media ? mediaServerSalts : serverSalts;

int32_t date = ConnectionsManager::getInstance(instanceNum).getCurrentTime();
std::vector<int64_t> existingSalts(salts.size());
std::vector<int64_t> existingSalts;
existingSalts.reserve(salts.size());
size_t size = salts.size();
for (uint32_t a = 0; a < size; a++) {
existingSalts.push_back(salts[a]->salt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true;
public static boolean TON_WALLET_STANDALONE = false;
public static int BUILD_VERSION = 1821;
public static int BUILD_VERSION = 1823;
public static String BUILD_VERSION_STRING = "5.13.0";
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 @@ -446,7 +446,7 @@ private void cancelLoadFile(final TLRPC.Document document, final SecureDocument
}

public boolean isLoadingFile(final String fileName) {
return loadOperationPathsUI.containsKey(fileName);
return fileName != null && loadOperationPathsUI.containsKey(fileName);
}

public float getBufferedProgressFromPosition(final float position, final String fileName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4523,7 +4523,10 @@ private TLRPC.TL_dialogFolder ensureFolderDialogExists(int folderId, boolean[] f
for (int a = 0; a < allDialogs.size(); a++) {
TLRPC.Dialog d = allDialogs.get(a);
if (!d.pinned) {
break;
if (d.id != proxyDialogId) {
break;
}
continue;
}
maxPinnedNum = Math.max(d.pinnedNum, maxPinnedNum);
}
Expand Down Expand Up @@ -8196,7 +8199,10 @@ public void reorderPinnedDialogs(int folderId, ArrayList<TLRPC.InputDialogPeer>
continue;
}
if (!dialog.pinned) {
break;
if (dialog.id != proxyDialogId) {
break;
}
continue;
}
getMessagesStorage().setDialogPinned(dialog.id, dialog.pinnedNum);
if ((int) dialog.id != 0) {
Expand Down Expand Up @@ -8250,7 +8256,10 @@ public boolean pinDialog(long did, boolean pin, TLRPC.InputPeer peer, long taskI
continue;
}
if (!d.pinned) {
break;
if (d.id != proxyDialogId) {
break;
}
continue;
}
maxPinnedNum = Math.max(d.pinnedNum, maxPinnedNum);
}
Expand Down Expand Up @@ -8413,7 +8422,10 @@ public void loadPinnedDialogs(final int folderId, final long newDialogId, final
continue;
}
if (!dialog.pinned) {
break;
if (dialog.id != proxyDialogId) {
break;
}
continue;
}
maxPinnedNum = Math.max(dialog.pinnedNum, maxPinnedNum);
dialog.pinned = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7261,16 +7261,14 @@ public void putMessages(final TLRPC.messages_Messages messages, final long dialo
message.attachPath = oldMessage.attachPath;
message.ttl = cursor.intValue(2);
}
if (!message.out) {
boolean sameMedia = false; //TODO check
if (oldMessage.media instanceof TLRPC.TL_messageMediaPhoto && message.media instanceof TLRPC.TL_messageMediaPhoto && oldMessage.media.photo != null && message.media.photo != null) {
sameMedia = oldMessage.media.photo.id == message.media.photo.id;
} else if (oldMessage.media instanceof TLRPC.TL_messageMediaDocument && message.media instanceof TLRPC.TL_messageMediaDocument && oldMessage.media.document != null && message.media.document != null) {
sameMedia = oldMessage.media.document.id == message.media.document.id;
}
if (!sameMedia) {
addFilesToDelete(oldMessage, filesToDelete, false);
}
boolean sameMedia = false;
if (oldMessage.media instanceof TLRPC.TL_messageMediaPhoto && message.media instanceof TLRPC.TL_messageMediaPhoto && oldMessage.media.photo != null && message.media.photo != null) {
sameMedia = oldMessage.media.photo.id == message.media.photo.id;
} else if (oldMessage.media instanceof TLRPC.TL_messageMediaDocument && message.media instanceof TLRPC.TL_messageMediaDocument && oldMessage.media.document != null && message.media.document != null) {
sameMedia = oldMessage.media.document.id == message.media.document.id;
}
if (!sameMedia) {
addFilesToDelete(oldMessage, filesToDelete, false);
}
}
boolean oldMention = cursor.intValue(3) != 0;
Expand Down
113 changes: 64 additions & 49 deletions TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java
Original file line number Diff line number Diff line change
Expand Up @@ -486,34 +486,7 @@ private Bitmap createWallpaperForAccent(Bitmap patternBitmap, boolean svg, File
if (svg) {
patternBitmap = SvgHelper.getBitmap(patternPath, AndroidUtilities.dp(360), AndroidUtilities.dp(640), false);
} else {
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = 1;
opts.inJustDecodeBounds = true;
BitmapFactory.decodeFile(patternPath.getAbsolutePath(), opts);
float photoW = opts.outWidth;
float photoH = opts.outHeight;
float scaleFactor;
int w_filter = AndroidUtilities.dp(360);
int h_filter = AndroidUtilities.dp(640);
if (w_filter >= h_filter && photoW > photoH) {
scaleFactor = Math.max(photoW / w_filter, photoH / h_filter);
} else {
scaleFactor = Math.min(photoW / w_filter, photoH / h_filter);
}
if (scaleFactor < 1.2f) {
scaleFactor = 1;
}
opts.inJustDecodeBounds = false;
if (scaleFactor > 1.0f && (photoW > w_filter || photoH > h_filter)) {
int sample = 1;
do {
sample *= 2;
} while (sample * 2 < scaleFactor);
opts.inSampleSize = sample;
} else {
opts.inSampleSize = (int) scaleFactor;
}
patternBitmap = BitmapFactory.decodeFile(patternPath.getAbsolutePath(), opts);
patternBitmap = loadScreenSizedBitmap(new FileInputStream(patternPath), 0);
}
}

Expand Down Expand Up @@ -7180,38 +7153,31 @@ public void onSizeReady(int width, int height) {
}
isCustomTheme = true;
} else if (themedWallpaperLink != null) {
File pathToWallpaper = new File(ApplicationLoader.getFilesDirFixed(), Utilities.MD5(themedWallpaperLink) + ".wp");
Bitmap bitmap = BitmapFactory.decodeFile(pathToWallpaper.getAbsolutePath());
if (bitmap != null) {
themedWallpaper = wallpaper = new BitmapDrawable(bitmap);
isCustomTheme = true;
try {
File pathToWallpaper = new File(ApplicationLoader.getFilesDirFixed(), Utilities.MD5(themedWallpaperLink) + ".wp");
Bitmap bitmap = loadScreenSizedBitmap(new FileInputStream(pathToWallpaper), 0);
if (bitmap != null) {
themedWallpaper = wallpaper = new BitmapDrawable(bitmap);
isCustomTheme = true;
}
} catch (Exception e) {
FileLog.e(e);
}
} else if (themedWallpaperFileOffset > 0 && (currentTheme.pathToFile != null || currentTheme.assetName != null)) {
FileInputStream stream = null;
try {
File file;
if (currentTheme.assetName != null) {
file = getAssetFile(currentTheme.assetName);
} else {
file = new File(currentTheme.pathToFile);
}
stream = new FileInputStream(file);
stream.getChannel().position(themedWallpaperFileOffset);
Bitmap bitmap = BitmapFactory.decodeStream(stream);
Bitmap bitmap = loadScreenSizedBitmap(new FileInputStream(file), themedWallpaperFileOffset);
if (bitmap != null) {
themedWallpaper = wallpaper = new BitmapDrawable(bitmap);
isCustomTheme = true;
}
} catch (Throwable e) {
FileLog.e(e);
} finally {
try {
if (stream != null) {
stream.close();
}
} catch (Exception e) {
FileLog.e(e);
}
}
}
}
Expand Down Expand Up @@ -7244,11 +7210,14 @@ public void onSizeReady(int width, int height) {
}
} else {
File toFile = new File(ApplicationLoader.getFilesDirFixed(), overrideWallpaper.fileName);
long len = toFile.length();
if (toFile.exists()) {
wallpaper = Drawable.createFromPath(toFile.getAbsolutePath());
isCustomTheme = true;
} else {
Bitmap bitmap = loadScreenSizedBitmap(new FileInputStream(toFile), 0);
if (bitmap != null) {
wallpaper = new BitmapDrawable(bitmap);
isCustomTheme = true;
}
}
if (wallpaper == null) {
wallpaper = ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.background_hd);
isCustomTheme = false;
}
Expand All @@ -7273,6 +7242,52 @@ public void onSizeReady(int width, int height) {
});
}

private static Bitmap loadScreenSizedBitmap(FileInputStream stream, int offset) {
try {
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = 1;
opts.inJustDecodeBounds = true;
stream.getChannel().position(offset);
BitmapFactory.decodeStream(stream, null, opts);
float photoW = opts.outWidth;
float photoH = opts.outHeight;
float scaleFactor;
int w_filter = AndroidUtilities.dp(360);
int h_filter = AndroidUtilities.dp(640);
if (w_filter >= h_filter && photoW > photoH) {
scaleFactor = Math.max(photoW / w_filter, photoH / h_filter);
} else {
scaleFactor = Math.min(photoW / w_filter, photoH / h_filter);
}
if (scaleFactor < 1.2f) {
scaleFactor = 1;
}
opts.inJustDecodeBounds = false;
if (scaleFactor > 1.0f && (photoW > w_filter || photoH > h_filter)) {
int sample = 1;
do {
sample *= 2;
} while (sample * 2 < scaleFactor);
opts.inSampleSize = sample;
} else {
opts.inSampleSize = (int) scaleFactor;
}
stream.getChannel().position(offset);
return BitmapFactory.decodeStream(stream, null, opts);
} catch (Exception e) {
FileLog.e(e);
} finally {
try {
if (stream != null) {
stream.close();
}
} catch (Exception ignore) {

}
}
return null;
}

public static Drawable getThemedWallpaper(boolean thumb, View ownerView) {
Integer backgroundColor = currentColors.get(key_chat_wallpaper);
File file = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType
@Override
public boolean onInterceptTouchEvent(MotionEvent e) {
if (getParent() != null && getParent().getParent() != null) {
getParent().getParent().requestDisallowInterceptTouchEvent(true);
getParent().getParent().requestDisallowInterceptTouchEvent(canScrollHorizontally(-1));
}
return super.onInterceptTouchEvent(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4746,6 +4746,9 @@ private void setMessageContent(MessageObject messageObject, MessageObject.Groupe
radialProgress.setIcon(getIconForCurrentState(), false, false);
}

if (delegate != null && delegate.getTextSelectionHelper() != null && !messageIdChanged && messageChanged && messageObject != null) {
delegate.getTextSelectionHelper().checkDataChanged(messageObject);
}
accessibilityVirtualViewBounds.clear();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1442,14 +1442,17 @@ public static class ChatListTextSelectionHelper extends TextSelectionHelper<Chat
protected int getLineHeight() {
if (selectedView != null && selectedView.getMessageObject() != null) {
MessageObject object = selectedView.getMessageObject();
StaticLayout layout;
StaticLayout layout = null;
if (isDescription) {
layout = selectedView.getDescriptionlayout();
} else if (selectedView.hasCaptionLayout()) {
layout = selectedView.getCaptionLayout();
} else {
} else if (object.textLayoutBlocks != null) {
layout = object.textLayoutBlocks.get(0).textLayout;
}
if (layout == null) {
return 0;
}
int lineHeight = layout.getLineBottom(0) - layout.getLineTop(0);
return lineHeight;
}
Expand All @@ -1461,7 +1464,7 @@ public void setMessageObject(ChatMessageCell chatMessageCell) {
this.maybeSelectedView = chatMessageCell;
MessageObject messageObject = chatMessageCell.getMessageObject();

if (maybeIsDescription) {
if (maybeIsDescription && chatMessageCell.getDescriptionlayout() != null) {
textArea.set(
maybeTextX, maybeTextY,
maybeTextX + chatMessageCell.getDescriptionlayout().getWidth(),
Expand Down Expand Up @@ -1673,6 +1676,11 @@ protected void fillLayoutForOffset(int offset, LayoutBlock layoutBlock, boolean
return;
}

if (messageObject.textLayoutBlocks == null) {
layoutBlock.layout = null;
return;
}

if (messageObject.textLayoutBlocks.size() == 1) {
layoutBlock.layout = messageObject.textLayoutBlocks.get(0).textLayout;
layoutBlock.yOffset = 0;
Expand Down Expand Up @@ -1802,6 +1810,12 @@ public void updateTextPosition(int textX, int textY) {
invalidate();
}
}

public void checkDataChanged(MessageObject messageObject) {
if (selectedCellId == messageObject.getId()) {
clear(true);
}
}
}

public static class ArticleTextSelectionHelper extends TextSelectionHelper<ArticleSelectableView> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ public void notifyDataSetChanged(int width) {
@Override
public boolean onInterceptTouchEvent(MotionEvent e) {
if (getParent() != null && getParent().getParent() != null) {
getParent().getParent().requestDisallowInterceptTouchEvent(true);
getParent().getParent().requestDisallowInterceptTouchEvent(canScrollHorizontally(-1));
}
return super.onInterceptTouchEvent(e);
}
Expand Down
Loading

0 comments on commit 12caa1e

Please sign in to comment.