From dd07a925ee3f25307808b263f775266c4cf6444d Mon Sep 17 00:00:00 2001 From: DrKLO Date: Sun, 5 Jan 2020 14:50:11 +0300 Subject: [PATCH] Update to 5.13.1 (1827) --- TMessagesProj/build.gradle | 2 +- .../jni/rlottie/src/lottie/lottieitem.cpp | 13 +- TMessagesProj/jni/tgnet/ConnectionSocket.cpp | 8 +- TMessagesProj/jni/tgnet/ConnectionSocket.h | 2 +- .../jni/tgnet/ConnectionsManager.cpp | 11 +- .../org/telegram/messenger/BuildVars.java | 2 +- .../telegram/messenger/MediaController.java | 2 +- .../org/telegram/messenger/MessageObject.java | 9 +- .../messenger/NotificationCenter.java | 2 +- .../messenger/SendMessagesHelper.java | 322 +++++++++--------- .../messenger/voip/VoIPBaseService.java | 2 +- .../telegram/ui/ActionBar/AlertDialog.java | 8 +- .../java/org/telegram/ui/ActionBar/Theme.java | 51 ++- .../ui/Adapters/SearchAdapterHelper.java | 2 +- .../java/org/telegram/ui/ArticleViewer.java | 2 +- .../telegram/ui/Cells/ChatMessageCell.java | 17 +- .../org/telegram/ui/Cells/DialogCell.java | 4 +- .../ui/Cells/TextSelectionHelper.java | 25 +- .../ui/Cells/ThemesHorizontalListCell.java | 1 + .../java/org/telegram/ui/ChatActivity.java | 62 ++-- .../ui/Components/AvatarDrawable.java | 4 +- .../ui/Components/ChatActivityEnterView.java | 6 + .../ui/Components/ChatAttachAlert.java | 3 + .../org/telegram/ui/Components/EmojiView.java | 2 +- .../ui/Components/FragmentContextView.java | 8 +- .../ui/Components/PhotoPaintView.java | 8 +- .../ui/Components/PullForegroundDrawable.java | 6 +- .../telegram/ui/Components/StickersAlert.java | 1 + .../java/org/telegram/ui/DialogsActivity.java | 2 +- .../java/org/telegram/ui/LaunchActivity.java | 8 +- .../org/telegram/ui/PaymentFormActivity.java | 4 +- .../java/org/telegram/ui/PhotoViewer.java | 11 +- .../ui/TooManyCommunitiesActivity.java | 6 +- 33 files changed, 352 insertions(+), 264 deletions(-) diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 546f3c369..160963bdc 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -283,7 +283,7 @@ android { } } - defaultConfig.versionCode = 1826 + defaultConfig.versionCode = 1827 applicationVariants.all { variant -> variant.outputs.all { output -> diff --git a/TMessagesProj/jni/rlottie/src/lottie/lottieitem.cpp b/TMessagesProj/jni/rlottie/src/lottie/lottieitem.cpp index 6fdd14ea5..979c39b8c 100755 --- a/TMessagesProj/jni/rlottie/src/lottie/lottieitem.cpp +++ b/TMessagesProj/jni/rlottie/src/lottie/lottieitem.cpp @@ -431,9 +431,8 @@ bool LOTLayerItem::resolveKeyPath(LOTKeyPath &keyPath, uint depth, } if (!keyPath.skip(name())) { - if (keyPath.fullyResolvesTo(name(), depth) && - transformProp(value.property())) { - //@TODO handle propery update. + if (keyPath.fullyResolvesTo(name(), depth) && transformProp(value.property())) { + mDirtyFlag = DirtyFlagBit::All; } } return true; @@ -445,7 +444,9 @@ bool LOTShapeLayerItem::resolveKeyPath(LOTKeyPath &keyPath, uint depth, if (LOTLayerItem::resolveKeyPath(keyPath, depth, value)) { if (keyPath.propagate(name(), depth)) { uint newDepth = keyPath.nextDepth(name(), depth); - mRoot->resolveKeyPath(keyPath, newDepth, value); + if (mRoot->resolveKeyPath(keyPath, newDepth, value)) { + mDirtyFlag = DirtyFlagBit::All; + } } return true; } @@ -459,7 +460,9 @@ bool LOTCompLayerItem::resolveKeyPath(LOTKeyPath &keyPath, uint depth, if (keyPath.propagate(name(), depth)) { uint newDepth = keyPath.nextDepth(name(), depth); for (const auto &layer : mLayers) { - layer->resolveKeyPath(keyPath, newDepth, value); + if (layer->resolveKeyPath(keyPath, newDepth, value)) { + mDirtyFlag = DirtyFlagBit::All; + } } } return true; diff --git a/TMessagesProj/jni/tgnet/ConnectionSocket.cpp b/TMessagesProj/jni/tgnet/ConnectionSocket.cpp index dd3dc0313..f288639b6 100644 --- a/TMessagesProj/jni/tgnet/ConnectionSocket.cpp +++ b/TMessagesProj/jni/tgnet/ConnectionSocket.cpp @@ -533,7 +533,9 @@ int32_t ConnectionSocket::checkSocketError(int32_t *error) { void ConnectionSocket::closeSocket(int32_t reason, int32_t error) { lastEventTime = ConnectionsManager::getInstance(instanceNum).getCurrentTimeMonotonicMillis(); - ConnectionsManager::getInstance(instanceNum).detachConnection(this); + if (reason != 2) { + ConnectionsManager::getInstance(instanceNum).detachConnection(this); + } if (socketFd >= 0) { epoll_ctl(ConnectionsManager::getInstance(instanceNum).epolFd, EPOLL_CTL_DEL, socketFd, nullptr); if (close(socketFd) != 0) { @@ -977,15 +979,17 @@ time_t ConnectionSocket::getTimeout() { return timeout; } -void ConnectionSocket::checkTimeout(int64_t now) { +bool ConnectionSocket::checkTimeout(int64_t now) { if (timeout != 0 && (now - lastEventTime) > (int64_t) timeout * 1000) { if (!onConnectedSent || hasPendingRequests()) { closeSocket(2, 0); + return true; } else { lastEventTime = ConnectionsManager::getInstance(instanceNum).getCurrentTimeMonotonicMillis(); if (LOGS_ENABLED) DEBUG_D("connection(%p) reset last event time, no requests", this); } } + return false; } bool ConnectionSocket::hasTlsHashMismatch() { diff --git a/TMessagesProj/jni/tgnet/ConnectionSocket.h b/TMessagesProj/jni/tgnet/ConnectionSocket.h index 16c0371d9..15ffee898 100644 --- a/TMessagesProj/jni/tgnet/ConnectionSocket.h +++ b/TMessagesProj/jni/tgnet/ConnectionSocket.h @@ -38,7 +38,7 @@ public: protected: int32_t instanceNum; void onEvent(uint32_t events); - void checkTimeout(int64_t now); + bool checkTimeout(int64_t now); void resetLastEventTime(); bool hasTlsHashMismatch(); virtual void onReceivedData(NativeByteBuffer *buffer) = 0; diff --git a/TMessagesProj/jni/tgnet/ConnectionsManager.cpp b/TMessagesProj/jni/tgnet/ConnectionsManager.cpp index 53cf68960..18b25431b 100644 --- a/TMessagesProj/jni/tgnet/ConnectionsManager.cpp +++ b/TMessagesProj/jni/tgnet/ConnectionsManager.cpp @@ -197,9 +197,12 @@ void ConnectionsManager::select() { EventObject *eventObject = (EventObject *) epollEvents[a].data.ptr; eventObject->onEvent(epollEvents[a].events); } - size_t count = activeConnections.size(); - for (uint32_t a = 0; a < count; a++) { - activeConnections[a]->checkTimeout(now); + for (std::vector::iterator iter = activeConnections.begin(); iter != activeConnections.end();) { + if ((*iter)->checkTimeout(now)) { + iter = activeConnections.erase(iter); + } else { + iter++; + } } Datacenter *datacenter = getDatacenterWithId(currentDatacenterId); @@ -2225,7 +2228,7 @@ void ConnectionsManager::processRequestQueue(uint32_t connectionTypes, uint32_t uint32_t retryMax = 10; if (!(request->requestFlags & RequestFlagForceDownload)) { if (request->failedByFloodWait) { - retryMax = 1; + retryMax = 2; } else { retryMax = 6; } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index 1e0020e2f..ec6352096 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -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 = 1826; + public static int BUILD_VERSION = 1827; public static String BUILD_VERSION_STRING = "5.13.0"; public static int APP_ID = 4; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java index 17e1f163e..fb94ca58a 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java @@ -2776,7 +2776,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, return true; } - public boolean resumeAudio(MessageObject messageObject) { + private boolean resumeAudio(MessageObject messageObject) { if (audioPlayer == null && videoPlayer == null || messageObject == null || playingMessageObject == null || !isSamePlayingMessage(messageObject)) { return false; } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java index 05433959e..c93c95a3e 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java @@ -403,8 +403,8 @@ public class MessageObject { isOut = messageObject.isOutOwner(); needShare = !isOut && ( messageObject.messageOwner.fwd_from != null && messageObject.messageOwner.fwd_from.saved_from_peer != null || - messageObject.messageOwner.from_id > 0 && (messageObject.messageOwner.to_id.channel_id != 0 || messageObject.messageOwner.to_id.chat_id != 0 || - messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGame || messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaInvoice) + messageObject.messageOwner.from_id > 0 && (messageObject.messageOwner.to_id.channel_id != 0 || messageObject.messageOwner.to_id.chat_id != 0 || + messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGame || messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaInvoice) ); } TLRPC.PhotoSize photoSize = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize()); @@ -1770,6 +1770,9 @@ public class MessageObject { } public static void updatePollResults(TLRPC.TL_messageMediaPoll media, TLRPC.TL_pollResults results) { + if (media == null || results == null) { + return; + } if ((results.flags & 2) != 0) { byte[] chosen = null; if (results.min && media.results.results != null) { @@ -3096,7 +3099,7 @@ public class MessageObject { matcher = instagramUrlPattern.matcher(charSequence); } else { if (urlPattern == null) { - urlPattern = Pattern.compile("(^|\\s)/[a-zA-Z@\\d_]{1,255}|(^|\\s|\\()@[a-zA-Z\\d_]{1,32}|(^|\\s|\\()#[\\w.]+|(^|\\s)\\$[A-Z]{3,8}([ ,.]|$)"); + urlPattern = Pattern.compile("(^|\\s)/[a-zA-Z@\\d_]{1,255}|(^|\\s|\\()@[a-zA-Z\\d_]{1,32}|(^|\\s|\\()#[^0-9][\\w.]+|(^|\\s)\\$[A-Z]{3,8}([ ,.]|$)"); } matcher = urlPattern.matcher(charSequence); } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationCenter.java b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationCenter.java index 1bc8d820f..34bb70f5c 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationCenter.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationCenter.java @@ -133,7 +133,7 @@ public class NotificationCenter { public static final int audioRouteChanged = totalEvents++; public static final int didStartedCall = totalEvents++; - public static final int didEndedCall = totalEvents++; + public static final int didEndCall = totalEvents++; public static final int closeInCallActivity = totalEvents++; public static final int appDidLogout = totalEvents++; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java index a264ef019..d943889a4 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java @@ -224,21 +224,18 @@ public class SendMessagesHelper extends BaseController implements NotificationCe if (locationQueryCancelRunnable != null) { AndroidUtilities.cancelRunOnUIThread(locationQueryCancelRunnable); } - locationQueryCancelRunnable = new Runnable() { - @Override - public void run() { - if (locationQueryCancelRunnable != this) { - return; - } - if (delegate != null) { - if (lastKnownLocation != null) { - delegate.onLocationAcquired(lastKnownLocation); - } else { - delegate.onUnableLocationAcquire(); - } - } - cleanup(); + locationQueryCancelRunnable = () -> { + if (locationQueryCancelRunnable != this) { + return; } + if (delegate != null) { + if (lastKnownLocation != null) { + delegate.onLocationAcquired(lastKnownLocation); + } else { + delegate.onUnableLocationAcquire(); + } + } + cleanup(); }; AndroidUtilities.runOnUIThread(locationQueryCancelRunnable, 5000); } @@ -1546,18 +1543,20 @@ public class SendMessagesHelper extends BaseController implements NotificationCe sentCount++; if (scheduleDate != 0 && !currentSchedule) { - ArrayList messageIds = new ArrayList<>(); - messageIds.add(oldId); - getMessagesController().deleteMessages(messageIds, null, null, newMsgObj1.dialog_id, newMsgObj1.to_id.channel_id, false, true); - getMessagesStorage().getStorageQueue().postRunnable(() -> { - getMessagesStorage().putMessages(sentMessages, true, false, false, 0, false); - AndroidUtilities.runOnUIThread(() -> { - ArrayList messageObjects = new ArrayList<>(); - messageObjects.add(new MessageObject(msgObj.currentAccount, msgObj.messageOwner, true)); - getMessagesController().updateInterfaceWithMessages(newMsgObj1.dialog_id, messageObjects, false); - getMediaDataController().increasePeerRaiting(newMsgObj1.dialog_id); - processSentMessage(oldId); - removeFromSendingMessages(oldId, scheduleDate != 0); + AndroidUtilities.runOnUIThread(() -> { + ArrayList messageIds = new ArrayList<>(); + messageIds.add(oldId); + getMessagesController().deleteMessages(messageIds, null, null, newMsgObj1.dialog_id, newMsgObj1.to_id.channel_id, false, true); + getMessagesStorage().getStorageQueue().postRunnable(() -> { + getMessagesStorage().putMessages(sentMessages, true, false, false, 0, false); + AndroidUtilities.runOnUIThread(() -> { + ArrayList messageObjects = new ArrayList<>(); + messageObjects.add(new MessageObject(msgObj.currentAccount, msgObj.messageOwner, true)); + getMessagesController().updateInterfaceWithMessages(newMsgObj1.dialog_id, messageObjects, false); + getMediaDataController().increasePeerRaiting(newMsgObj1.dialog_id); + processSentMessage(oldId); + removeFromSendingMessages(oldId, scheduleDate != 0); + }); }); }); } else { @@ -2068,13 +2067,10 @@ public class SendMessagesHelper extends BaseController implements NotificationCe getMessagesController().processUpdates((TLRPC.Updates) response, false); voteSendTime.put(messageObject.getPollId(), SystemClock.uptimeMillis()); } - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - waitingForVote.remove(key); - if (finishRunnable != null) { - finishRunnable.run(); - } + AndroidUtilities.runOnUIThread(() -> { + waitingForVote.remove(key); + if (finishRunnable != null) { + finishRunnable.run(); } }); }); @@ -4037,143 +4033,142 @@ public class SendMessagesHelper extends BaseController implements NotificationCe for (int a = 0, size = msgObjs.size(); a < size; a++) { putToSendingMessages(msgObjs.get(a).messageOwner, scheduled); } - getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { + getConnectionsManager().sendRequest(req, (response, error) -> { if (error != null && FileRefController.isFileRefError(error.text)) { if (parentObjects != null) { ArrayList arrayList = new ArrayList<>(parentObjects); getFileRefController().requestReference(arrayList, req, msgObjs, originalPaths, arrayList, delayedMessage, scheduled); return; } else if (delayedMessage != null) { - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - for (int a = 0, size = req.multi_media.size(); a < size; a++) { - if (delayedMessage.parentObjects.get(a) == null) { - continue; - } - removeFromSendingMessages(msgObjs.get(a).getId(), scheduled); - TLRPC.TL_inputSingleMedia request = req.multi_media.get(a); - if (request.media instanceof TLRPC.TL_inputMediaPhoto) { - request.media = delayedMessage.inputMedias.get(a); - } else if (request.media instanceof TLRPC.TL_inputMediaDocument) { - request.media = delayedMessage.inputMedias.get(a); - } - delayedMessage.videoEditedInfo = delayedMessage.videoEditedInfos.get(a); - delayedMessage.httpLocation = delayedMessage.httpLocations.get(a); - delayedMessage.photoSize = delayedMessage.locations.get(a); - delayedMessage.performMediaUpload = true; - performSendDelayedMessage(delayedMessage, a); + AndroidUtilities.runOnUIThread(() -> { + for (int a = 0, size = req.multi_media.size(); a < size; a++) { + if (delayedMessage.parentObjects.get(a) == null) { + continue; } + removeFromSendingMessages(msgObjs.get(a).getId(), scheduled); + TLRPC.TL_inputSingleMedia request = req.multi_media.get(a); + if (request.media instanceof TLRPC.TL_inputMediaPhoto) { + request.media = delayedMessage.inputMedias.get(a); + } else if (request.media instanceof TLRPC.TL_inputMediaDocument) { + request.media = delayedMessage.inputMedias.get(a); + } + delayedMessage.videoEditedInfo = delayedMessage.videoEditedInfos.get(a); + delayedMessage.httpLocation = delayedMessage.httpLocations.get(a); + delayedMessage.photoSize = delayedMessage.locations.get(a); + delayedMessage.performMediaUpload = true; + performSendDelayedMessage(delayedMessage, a); } }); return; } } - boolean isSentError = false; - if (error == null) { - SparseArray newMessages = new SparseArray<>(); - LongSparseArray newIds = new LongSparseArray<>(); - final TLRPC.Updates updates = (TLRPC.Updates) response; - ArrayList updatesArr = ((TLRPC.Updates) response).updates; - for (int a = 0; a < updatesArr.size(); a++) { - TLRPC.Update update = updatesArr.get(a); - if (update instanceof TLRPC.TL_updateMessageID) { - TLRPC.TL_updateMessageID updateMessageID = (TLRPC.TL_updateMessageID) update; - newIds.put(updateMessageID.random_id, updateMessageID.id); - updatesArr.remove(a); - a--; - } else if (update instanceof TLRPC.TL_updateNewMessage) { - final TLRPC.TL_updateNewMessage newMessage = (TLRPC.TL_updateNewMessage) update; - newMessages.put(newMessage.message.id, newMessage.message); - Utilities.stageQueue.postRunnable(() -> getMessagesController().processNewDifferenceParams(-1, newMessage.pts, -1, newMessage.pts_count)); - updatesArr.remove(a); - a--; - } else if (update instanceof TLRPC.TL_updateNewChannelMessage) { - final TLRPC.TL_updateNewChannelMessage newMessage = (TLRPC.TL_updateNewChannelMessage) update; - newMessages.put(newMessage.message.id, newMessage.message); - Utilities.stageQueue.postRunnable(() -> getMessagesController().processNewChannelDifferenceParams(newMessage.pts, newMessage.pts_count, newMessage.message.to_id.channel_id)); - updatesArr.remove(a); - a--; - } else if (update instanceof TLRPC.TL_updateNewScheduledMessage) { - final TLRPC.TL_updateNewScheduledMessage newMessage = (TLRPC.TL_updateNewScheduledMessage) update; - newMessages.put(newMessage.message.id, newMessage.message); - updatesArr.remove(a); - a--; + AndroidUtilities.runOnUIThread(() -> { + boolean isSentError = false; + if (error == null) { + SparseArray newMessages = new SparseArray<>(); + LongSparseArray newIds = new LongSparseArray<>(); + final TLRPC.Updates updates = (TLRPC.Updates) response; + ArrayList updatesArr = ((TLRPC.Updates) response).updates; + for (int a = 0; a < updatesArr.size(); a++) { + TLRPC.Update update = updatesArr.get(a); + if (update instanceof TLRPC.TL_updateMessageID) { + TLRPC.TL_updateMessageID updateMessageID = (TLRPC.TL_updateMessageID) update; + newIds.put(updateMessageID.random_id, updateMessageID.id); + updatesArr.remove(a); + a--; + } else if (update instanceof TLRPC.TL_updateNewMessage) { + final TLRPC.TL_updateNewMessage newMessage = (TLRPC.TL_updateNewMessage) update; + newMessages.put(newMessage.message.id, newMessage.message); + Utilities.stageQueue.postRunnable(() -> getMessagesController().processNewDifferenceParams(-1, newMessage.pts, -1, newMessage.pts_count)); + updatesArr.remove(a); + a--; + } else if (update instanceof TLRPC.TL_updateNewChannelMessage) { + final TLRPC.TL_updateNewChannelMessage newMessage = (TLRPC.TL_updateNewChannelMessage) update; + newMessages.put(newMessage.message.id, newMessage.message); + Utilities.stageQueue.postRunnable(() -> getMessagesController().processNewChannelDifferenceParams(newMessage.pts, newMessage.pts_count, newMessage.message.to_id.channel_id)); + updatesArr.remove(a); + a--; + } else if (update instanceof TLRPC.TL_updateNewScheduledMessage) { + final TLRPC.TL_updateNewScheduledMessage newMessage = (TLRPC.TL_updateNewScheduledMessage) update; + newMessages.put(newMessage.message.id, newMessage.message); + updatesArr.remove(a); + a--; + } } - } - for (int i = 0; i < msgObjs.size(); i++) { - final MessageObject msgObj = msgObjs.get(i); - final String originalPath = originalPaths.get(i); - final TLRPC.Message newMsgObj = msgObj.messageOwner; - final int oldId = newMsgObj.id; - final ArrayList sentMessages = new ArrayList<>(); - final String attachPath = newMsgObj.attachPath; - final long grouped_id; - final int existFlags; + for (int i = 0; i < msgObjs.size(); i++) { + final MessageObject msgObj = msgObjs.get(i); + final String originalPath = originalPaths.get(i); + final TLRPC.Message newMsgObj = msgObj.messageOwner; + final int oldId = newMsgObj.id; + final ArrayList sentMessages = new ArrayList<>(); + final String attachPath = newMsgObj.attachPath; + final long grouped_id; + final int existFlags; - Integer id = newIds.get(newMsgObj.random_id); - if (id != null) { - TLRPC.Message message = newMessages.get(id); - if (message != null) { - sentMessages.add(message); - updateMediaPaths(msgObj, message, message.id, originalPath, false); - existFlags = msgObj.getMediaExistanceFlags(); - newMsgObj.id = message.id; - if ((newMsgObj.flags & TLRPC.MESSAGE_FLAG_MEGAGROUP) != 0) { - message.flags |= TLRPC.MESSAGE_FLAG_MEGAGROUP; - } - grouped_id = message.grouped_id; - - if (!scheduled) { - Integer value = getMessagesController().dialogs_read_outbox_max.get(message.dialog_id); - if (value == null) { - value = getMessagesStorage().getDialogReadMax(message.out, message.dialog_id); - getMessagesController().dialogs_read_outbox_max.put(message.dialog_id, value); + Integer id = newIds.get(newMsgObj.random_id); + if (id != null) { + TLRPC.Message message = newMessages.get(id); + if (message != null) { + sentMessages.add(message); + updateMediaPaths(msgObj, message, message.id, originalPath, false); + existFlags = msgObj.getMediaExistanceFlags(); + newMsgObj.id = message.id; + if ((newMsgObj.flags & TLRPC.MESSAGE_FLAG_MEGAGROUP) != 0) { + message.flags |= TLRPC.MESSAGE_FLAG_MEGAGROUP; } - message.unread = value < message.id; + grouped_id = message.grouped_id; + + if (!scheduled) { + Integer value = getMessagesController().dialogs_read_outbox_max.get(message.dialog_id); + if (value == null) { + value = getMessagesStorage().getDialogReadMax(message.out, message.dialog_id); + getMessagesController().dialogs_read_outbox_max.put(message.dialog_id, value); + } + message.unread = value < message.id; + } + } else { + isSentError = true; + break; } } else { isSentError = true; break; } - } else { - isSentError = true; - break; - } - if (!isSentError) { - getStatsController().incrementSentItemsCount(ApplicationLoader.getCurrentNetworkType(), StatsController.TYPE_MESSAGES, 1); - newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT; - getNotificationCenter().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, newMsgObj.id, newMsgObj, newMsgObj.dialog_id, grouped_id, existFlags, scheduled); - getMessagesStorage().getStorageQueue().postRunnable(() -> { - getMessagesStorage().updateMessageStateAndId(newMsgObj.random_id, oldId, newMsgObj.id, 0, false, newMsgObj.to_id.channel_id, scheduled ? 1 : 0); - getMessagesStorage().putMessages(sentMessages, true, false, false, 0, scheduled); - AndroidUtilities.runOnUIThread(() -> { - getMediaDataController().increasePeerRaiting(newMsgObj.dialog_id); - getNotificationCenter().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, newMsgObj.id, newMsgObj, newMsgObj.dialog_id, grouped_id, existFlags, scheduled); - processSentMessage(oldId); - removeFromSendingMessages(oldId, scheduled); + if (!isSentError) { + getStatsController().incrementSentItemsCount(ApplicationLoader.getCurrentNetworkType(), StatsController.TYPE_MESSAGES, 1); + newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT; + getNotificationCenter().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, newMsgObj.id, newMsgObj, newMsgObj.dialog_id, grouped_id, existFlags, scheduled); + getMessagesStorage().getStorageQueue().postRunnable(() -> { + getMessagesStorage().updateMessageStateAndId(newMsgObj.random_id, oldId, newMsgObj.id, 0, false, newMsgObj.to_id.channel_id, scheduled ? 1 : 0); + getMessagesStorage().putMessages(sentMessages, true, false, false, 0, scheduled); + AndroidUtilities.runOnUIThread(() -> { + getMediaDataController().increasePeerRaiting(newMsgObj.dialog_id); + getNotificationCenter().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, newMsgObj.id, newMsgObj, newMsgObj.dialog_id, grouped_id, existFlags, scheduled); + processSentMessage(oldId); + removeFromSendingMessages(oldId, scheduled); + }); }); - }); + } + } + Utilities.stageQueue.postRunnable(() -> getMessagesController().processUpdates(updates, false)); + } else { + AlertsCreator.processError(currentAccount, error, null, req); + isSentError = true; + } + if (isSentError) { + for (int i = 0; i < msgObjs.size(); i++) { + TLRPC.Message newMsgObj = msgObjs.get(i).messageOwner; + getMessagesStorage().markMessageAsSendError(newMsgObj, scheduled); + newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR; + getNotificationCenter().postNotificationName(NotificationCenter.messageSendError, newMsgObj.id); + processSentMessage(newMsgObj.id); + removeFromSendingMessages(newMsgObj.id, scheduled); } } - Utilities.stageQueue.postRunnable(() -> getMessagesController().processUpdates(updates, false)); - } else { - AlertsCreator.processError(currentAccount, error, null, req); - isSentError = true; - } - if (isSentError) { - for (int i = 0; i < msgObjs.size(); i++) { - TLRPC.Message newMsgObj = msgObjs.get(i).messageOwner; - getMessagesStorage().markMessageAsSendError(newMsgObj, scheduled); - newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR; - getNotificationCenter().postNotificationName(NotificationCenter.messageSendError, newMsgObj.id); - processSentMessage(newMsgObj.id); - removeFromSendingMessages(newMsgObj.id, scheduled); - } - } - }), null, ConnectionsManager.RequestFlagCanCompress | ConnectionsManager.RequestFlagInvokeAfter); + }); + }, null, ConnectionsManager.RequestFlagCanCompress | ConnectionsManager.RequestFlagInvokeAfter); } private void performSendMessageRequest(final TLObject req, final MessageObject msgObj, final String originalPath, DelayedMessage delayedMessage, Object parentObject, boolean scheduled) { @@ -4228,28 +4223,25 @@ public class SendMessagesHelper extends BaseController implements NotificationCe getFileRefController().requestReference(parentObject, req, msgObj, originalPath, parentMessage, check, delayedMessage, scheduled); return; } else if (delayedMessage != null) { - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - removeFromSendingMessages(newMsgObj.id, scheduled); - if (req instanceof TLRPC.TL_messages_sendMedia) { - TLRPC.TL_messages_sendMedia request = (TLRPC.TL_messages_sendMedia) req; - if (request.media instanceof TLRPC.TL_inputMediaPhoto) { - request.media = delayedMessage.inputUploadMedia; - } else if (request.media instanceof TLRPC.TL_inputMediaDocument) { - request.media = delayedMessage.inputUploadMedia; - } - } else if (req instanceof TLRPC.TL_messages_editMessage) { - TLRPC.TL_messages_editMessage request = (TLRPC.TL_messages_editMessage) req; - if (request.media instanceof TLRPC.TL_inputMediaPhoto) { - request.media = delayedMessage.inputUploadMedia; - } else if (request.media instanceof TLRPC.TL_inputMediaDocument) { - request.media = delayedMessage.inputUploadMedia; - } + AndroidUtilities.runOnUIThread(() -> { + removeFromSendingMessages(newMsgObj.id, scheduled); + if (req instanceof TLRPC.TL_messages_sendMedia) { + TLRPC.TL_messages_sendMedia request = (TLRPC.TL_messages_sendMedia) req; + if (request.media instanceof TLRPC.TL_inputMediaPhoto) { + request.media = delayedMessage.inputUploadMedia; + } else if (request.media instanceof TLRPC.TL_inputMediaDocument) { + request.media = delayedMessage.inputUploadMedia; + } + } else if (req instanceof TLRPC.TL_messages_editMessage) { + TLRPC.TL_messages_editMessage request = (TLRPC.TL_messages_editMessage) req; + if (request.media instanceof TLRPC.TL_inputMediaPhoto) { + request.media = delayedMessage.inputUploadMedia; + } else if (request.media instanceof TLRPC.TL_inputMediaDocument) { + request.media = delayedMessage.inputUploadMedia; } - delayedMessage.performMediaUpload = true; - performSendDelayedMessage(delayedMessage); } + delayedMessage.performMediaUpload = true; + performSendDelayedMessage(delayedMessage); }); return; } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/voip/VoIPBaseService.java b/TMessagesProj/src/main/java/org/telegram/messenger/voip/VoIPBaseService.java index e1bdb9096..c217d72d3 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/voip/VoIPBaseService.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/voip/VoIPBaseService.java @@ -594,7 +594,7 @@ public abstract class VoIPBaseService extends Service implements SensorEventList AndroidUtilities.runOnUIThread(new Runnable(){ @Override public void run(){ - NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didEndedCall); + NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didEndCall); } }); if (controller != null && controllerStarted) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AlertDialog.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AlertDialog.java index 516474c74..ba0925a5d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AlertDialog.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AlertDialog.java @@ -112,7 +112,12 @@ public class AlertDialog extends Dialog implements Drawable.Callback { private Rect backgroundPaddings; private Runnable dismissRunnable = this::dismiss; - private Runnable showRunnable = this::show; + private Runnable showRunnable = () -> { + if (isShowing()) { + return; + } + show(); + }; private ArrayList itemViews = new ArrayList<>(); @@ -1026,6 +1031,7 @@ public class AlertDialog extends Dialog implements Drawable.Callback { } public void showDelayed(long delay) { + AndroidUtilities.cancelRunOnUIThread(showRunnable); AndroidUtilities.runOnUIThread(showRunnable, delay); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java index 694209e83..c6d2f46bc 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java @@ -1167,6 +1167,9 @@ public class Theme { } ThemeAccent defaultAccent = themeAccentsMap.get(DEFALT_THEME_ACCENT_ID); ThemeAccent accent = themeAccentsMap.get(currentAccentId); + if (defaultAccent == null || accent == null) { + return false; + } return defaultAccent.myMessagesAccentColor == accent.myMessagesAccentColor && defaultAccent.myMessagesGradientAccentColor == accent.myMessagesGradientAccentColor; } @@ -5996,28 +5999,38 @@ public class Theme { setDrawableColorByKey(avatar_savedDrawable, key_avatar_text); - dialogs_archiveAvatarDrawable.setLayerColor("Arrow1.**", getColor(key_avatar_backgroundArchived)); - dialogs_archiveAvatarDrawable.setLayerColor("Arrow2.**", getColor(key_avatar_backgroundArchived)); - dialogs_archiveAvatarDrawable.setLayerColor("Box2.**", getColor(key_avatar_text)); - dialogs_archiveAvatarDrawable.setLayerColor("Box1.**", getColor(key_avatar_text)); + dialogs_archiveAvatarDrawable.beginApplyLayerColors(); + dialogs_archiveAvatarDrawable.setLayerColor("Arrow1.**", getNonAnimatedColor(key_avatar_backgroundArchived)); + dialogs_archiveAvatarDrawable.setLayerColor("Arrow2.**", getNonAnimatedColor(key_avatar_backgroundArchived)); + dialogs_archiveAvatarDrawable.setLayerColor("Box2.**", getNonAnimatedColor(key_avatar_text)); + dialogs_archiveAvatarDrawable.setLayerColor("Box1.**", getNonAnimatedColor(key_avatar_text)); + dialogs_archiveAvatarDrawable.commitApplyLayerColors(); dialogs_archiveAvatarDrawableRecolored = false; dialogs_archiveAvatarDrawable.setAllowDecodeSingleFrame(true); - - dialogs_pinArchiveDrawable.setLayerColor("Arrow.**", getColor(key_chats_archiveIcon)); - dialogs_pinArchiveDrawable.setLayerColor("Line.**", getColor(key_chats_archiveIcon)); - - dialogs_unpinArchiveDrawable.setLayerColor("Arrow.**", getColor(key_chats_archiveIcon)); - dialogs_unpinArchiveDrawable.setLayerColor("Line.**", getColor(key_chats_archiveIcon)); - dialogs_archiveDrawable.setLayerColor("Arrow.**", getColor(key_chats_archiveBackground)); - dialogs_archiveDrawable.setLayerColor("Box2.**", getColor(key_chats_archiveIcon)); - dialogs_archiveDrawable.setLayerColor("Box1.**", getColor(key_chats_archiveIcon)); + dialogs_pinArchiveDrawable.beginApplyLayerColors(); + dialogs_pinArchiveDrawable.setLayerColor("Arrow.**", getNonAnimatedColor(key_chats_archiveIcon)); + dialogs_pinArchiveDrawable.setLayerColor("Line.**", getNonAnimatedColor(key_chats_archiveIcon)); + dialogs_pinArchiveDrawable.commitApplyLayerColors(); + + dialogs_unpinArchiveDrawable.beginApplyLayerColors(); + dialogs_unpinArchiveDrawable.setLayerColor("Arrow.**", getNonAnimatedColor(key_chats_archiveIcon)); + dialogs_unpinArchiveDrawable.setLayerColor("Line.**", getNonAnimatedColor(key_chats_archiveIcon)); + dialogs_unpinArchiveDrawable.commitApplyLayerColors(); + + dialogs_archiveDrawable.beginApplyLayerColors(); + dialogs_archiveDrawable.setLayerColor("Arrow.**", getNonAnimatedColor(key_chats_archiveBackground)); + dialogs_archiveDrawable.setLayerColor("Box2.**", getNonAnimatedColor(key_chats_archiveIcon)); + dialogs_archiveDrawable.setLayerColor("Box1.**", getNonAnimatedColor(key_chats_archiveIcon)); + dialogs_archiveDrawable.commitApplyLayerColors(); dialogs_archiveDrawableRecolored = false; - dialogs_unarchiveDrawable.setLayerColor("Arrow1.**", getColor(key_chats_archiveIcon)); - dialogs_unarchiveDrawable.setLayerColor("Arrow2.**", getColor(key_chats_archivePinBackground)); - dialogs_unarchiveDrawable.setLayerColor("Box2.**", getColor(key_chats_archiveIcon)); - dialogs_unarchiveDrawable.setLayerColor("Box1.**", getColor(key_chats_archiveIcon)); + dialogs_unarchiveDrawable.beginApplyLayerColors(); + dialogs_unarchiveDrawable.setLayerColor("Arrow1.**", getNonAnimatedColor(key_chats_archiveIcon)); + dialogs_unarchiveDrawable.setLayerColor("Arrow2.**", getNonAnimatedColor(key_chats_archivePinBackground)); + dialogs_unarchiveDrawable.setLayerColor("Box2.**", getNonAnimatedColor(key_chats_archiveIcon)); + dialogs_unarchiveDrawable.setLayerColor("Box1.**", getNonAnimatedColor(key_chats_archiveIcon)); + dialogs_unarchiveDrawable.commitApplyLayerColors(); } public static void createDialogsResources(Context context) { @@ -6835,6 +6848,10 @@ public class Theme { return 0; } + public static int getNonAnimatedColor(String key) { + return getColor(key, null, true); + } + public static int getColor(String key) { return getColor(key, null, false); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/SearchAdapterHelper.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/SearchAdapterHelper.java index e98a4bfb7..4f4dc08c4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/SearchAdapterHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/SearchAdapterHelper.java @@ -401,7 +401,7 @@ public class SearchAdapterHelper { return; } boolean changed = false; - Pattern pattern = Pattern.compile("(^|\\s)#[\\w@.]+"); + Pattern pattern = Pattern.compile("(^|\\s)#[^0-9][\\w@.]+"); Matcher matcher = pattern.matcher(message); while (matcher.find()) { int start = matcher.start(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java index 16a2cb426..1e410bad9 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java @@ -884,7 +884,7 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg listView[1].setAlpha(1.0f); listView[1].setTranslationX(0.0f); listView[0].setBackgroundColor(backgroundPaint.getColor()); - updateInterfaceForCurrentPage(true, 0); + updateInterfaceForCurrentPage(true, -1); } else { movingPage = false; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java index 451a01017..dbb7a973c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -5629,6 +5629,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate needNewVisiblePart = false; } forceNotDrawTime = currentMessagesGroup != null; + photoImage.setPressed((isHighlightedAnimated || isHighlighted) && currentPosition != null ? 2 : 0); photoImage.setVisible(!PhotoViewer.isShowingImage(currentMessageObject) && !SecretMediaViewer.getInstance().isShowingImage(currentMessageObject), false); if (!photoImage.getVisible()) { mediaWasInvisible = true; @@ -6540,6 +6541,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } public void updateButtonState(boolean ifSame, boolean animated, boolean fromSet) { + if (currentMessageObject == null) { + return; + } if (animated && (PhotoViewer.isShowingImage(currentMessageObject) || !attachedToWindow)) { animated = false; } @@ -7964,14 +7968,15 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate Drawable drawable = a == 0 ? currentBackgroundDrawable : currentBackgroundSelectedDrawable; if (drawable instanceof Theme.MessageDrawable) { Theme.MessageDrawable messageDrawable = (Theme.MessageDrawable) drawable; - if (parentHeight == 0) { - parentHeight = AndroidUtilities.displaySize.y; + int h = parentHeight; + if (h == 0) { + h = AndroidUtilities.displaySize.y; if (getParent() instanceof View) { View view = (View) getParent(); - parentHeight = view.getMeasuredHeight(); + h = view.getMeasuredHeight(); } } - messageDrawable.setTop(getTop(), parentHeight); + messageDrawable.setTop(getTop(), h); } } if (isHighlightedAnimated) { @@ -9186,7 +9191,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate AccessibilityEvent event = AccessibilityEvent.obtain(eventType); event.setPackageName(getContext().getPackageName()); event.setSource(ChatMessageCell.this, viewId); - getParent().requestSendAccessibilityEvent(ChatMessageCell.this, event); + if (getParent() != null) { + getParent().requestSendAccessibilityEvent(ChatMessageCell.this, event); + } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java index 5ac3a1316..73a81b0e6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java @@ -1724,7 +1724,7 @@ public class DialogCell extends BaseCell { Theme.dialogs_pinnedPaint.setColor(backgroundColor); canvas.drawRect(tx - AndroidUtilities.dp(8), 0, getMeasuredWidth(), getMeasuredHeight(), Theme.dialogs_pinnedPaint); if (currentRevealProgress == 0 && Theme.dialogs_archiveDrawableRecolored) { - Theme.dialogs_archiveDrawable.setLayerColor("Arrow.**", Theme.getColor(Theme.key_chats_archiveBackground)); + Theme.dialogs_archiveDrawable.setLayerColor("Arrow.**", Theme.getNonAnimatedColor(Theme.key_chats_archiveBackground)); Theme.dialogs_archiveDrawableRecolored = false; } } @@ -1743,7 +1743,7 @@ public class DialogCell extends BaseCell { canvas.restore(); if (!Theme.dialogs_archiveDrawableRecolored) { - Theme.dialogs_archiveDrawable.setLayerColor("Arrow.**", Theme.getColor(Theme.key_chats_archivePinBackground)); + Theme.dialogs_archiveDrawable.setLayerColor("Arrow.**", Theme.getNonAnimatedColor(Theme.key_chats_archivePinBackground)); Theme.dialogs_archiveDrawableRecolored = true; } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSelectionHelper.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSelectionHelper.java index 253c63b17..7aaf6f4ff 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSelectionHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSelectionHelper.java @@ -1315,7 +1315,9 @@ public abstract class TextSelectionHelper 1) { + if (selectedMessageObject.textLayoutBlocks.size() > 1) { if (selectionStart < block.charactersOffset) { selectionStart = block.charactersOffset; } @@ -2334,9 +2340,17 @@ public abstract class TextSelectionHelper text.length()) e = text.length(); stringBuilder.append(text.subSequence(s, e)); @@ -2369,6 +2383,9 @@ public abstract class TextSelectionHelper postponedScrollIsCanceled = true); progressDialog.showDelayed(400); @@ -7264,7 +7267,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (forwardingMessages != null) { ArrayList messagesToForward = forwardingMessages; forwardingMessages = null; - forwardMessages(messagesToForward, false, notify, scheduleDate != 0 && scheduleDate != 0x7ffffffe ? scheduleDate + 1 : 0); + forwardMessages(messagesToForward, false, notify, scheduleDate != 0 && scheduleDate != 0x7ffffffe ? scheduleDate + 1 : scheduleDate); } chatActivityEnterView.setForceShowSendButton(false, false); chatActivityEnterView.hideTopView(animated); @@ -7370,9 +7373,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } else { if (pagedown) { - if (progressDialog == null) { - progressDialog = new AlertDialog(getParentActivity(), 3); + if (progressDialog != null) { + progressDialog.dismiss(); } + progressDialog = new AlertDialog(getParentActivity(), 3); progressDialog.setOnCancelListener(dialog -> postponedScrollIsCanceled = true); progressDialog.showDelayed(400); @@ -7763,8 +7767,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private AlertDialog progressDialog; - public void - scrollToMessageId(int id, int fromMessageId, boolean select, int loadIndex, boolean forceScroll) { + public void scrollToMessageId(int id, int fromMessageId, boolean select, int loadIndex, boolean forceScroll) { if (chatListView.animationRunning || getParentActivity() == null) { return; } @@ -7804,7 +7807,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not MessageObject primary = groupedMessages.findPrimaryMessageObject(); if (primary != null) { object = primary; - id = object.getId(); } } @@ -7841,7 +7843,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (found) { int yOffset = getScrollOffsetForMessage(object); - chatListView.smoothScrollBy(0,view.getTop() - chatListView.getPaddingTop() - yOffset); + int scrollY = view.getTop() - chatListView.getPaddingTop() - yOffset; + int maxScrollOffset = chatListView.computeVerticalScrollRange() - chatListView.computeVerticalScrollOffset() - chatListView.computeVerticalScrollExtent(); + if (maxScrollOffset < 0) maxScrollOffset = 0; + if (scrollY > maxScrollOffset) { + scrollY = maxScrollOffset; + } + if (scrollY != 0) { + chatListView.smoothScrollBy(0, scrollY); + } break; } } @@ -7887,13 +7897,22 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (h < maxH) { int yOffset = getScrollOffsetForMessage(object); if (view != null) { + int scrollY; if (scrollDirection == RecyclerAnimationScrollHelper.SCROLL_DIRECTION_UP) { - chatListView.smoothScrollBy(0, view.getTop() - chatListView.getPaddingTop() - h - yOffset); + scrollY= view.getTop() - chatListView.getPaddingTop() - h - yOffset; } else { MessageObject messageObject = messages.get(position - chatAdapter.messagesStartRow); int scrollToHeight = dummyMessageCell.computeHeight(messageObject, groupedMessagesMap.get(messageObject.getGroupId())); int t = chatListView.getMeasuredHeight() - scrollToHeight; - chatListView.smoothScrollBy(0, -(chatListView.getMeasuredHeight() - view.getBottom()) + t + h - yOffset); + scrollY= -(chatListView.getMeasuredHeight() - view.getBottom()) + t + h - yOffset; + } + int maxScrollOffset = chatListView.computeVerticalScrollRange() - chatListView.computeVerticalScrollOffset() - chatListView.computeVerticalScrollExtent(); + if (maxScrollOffset < 0) maxScrollOffset = 0; + if (scrollY > maxScrollOffset) { + scrollY = maxScrollOffset; + } + if (scrollY != 0) { + chatListView.smoothScrollBy(0, scrollY); } } else { chatListView.smoothScrollToPosition(position); @@ -7916,9 +7935,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } if (query) { - if (progressDialog == null) { - progressDialog = new AlertDialog(getParentActivity(), 3); + if (progressDialog != null) { + progressDialog.dismiss(); } + progressDialog = new AlertDialog(getParentActivity(), 3); progressDialog.setOnCancelListener(dialog -> postponedScrollIsCanceled = true); progressDialog.showDelayed(400); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java index a62f6325b..cdf0a23c7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java @@ -251,8 +251,8 @@ public class AvatarDrawable extends Drawable { canvas.drawCircle(size / 2.0f, size / 2.0f, size / 2.0f * archivedAvatarProgress, Theme.avatar_backgroundPaint); if (Theme.dialogs_archiveAvatarDrawableRecolored) { Theme.dialogs_archiveAvatarDrawable.beginApplyLayerColors(); - Theme.dialogs_archiveAvatarDrawable.setLayerColor("Arrow1.**", Theme.getColor(Theme.key_avatar_backgroundArchived)); - Theme.dialogs_archiveAvatarDrawable.setLayerColor("Arrow2.**", Theme.getColor(Theme.key_avatar_backgroundArchived)); + Theme.dialogs_archiveAvatarDrawable.setLayerColor("Arrow1.**", Theme.getNonAnimatedColor(Theme.key_avatar_backgroundArchived)); + Theme.dialogs_archiveAvatarDrawable.setLayerColor("Arrow2.**", Theme.getNonAnimatedColor(Theme.key_avatar_backgroundArchived)); Theme.dialogs_archiveAvatarDrawable.commitApplyLayerColors(); Theme.dialogs_archiveAvatarDrawableRecolored = false; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java index a1c49ffc8..03c026a00 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java @@ -2774,6 +2774,9 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe }); runningAnimation2.start(); updateFieldRight(0); + if (delegate != null && getVisibility() == VISIBLE) { + delegate.onAttachButtonHidden(); + } } runningAnimationType = 5; @@ -2856,6 +2859,9 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe } if (attachLayout != null) { attachLayout.setVisibility(GONE); + if (delegate != null && getVisibility() == VISIBLE) { + delegate.onAttachButtonHidden(); + } updateFieldRight(0); } scheduleButtonHidden = false; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java index bc92d77ee..f83f0f750 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java @@ -3495,6 +3495,9 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N } public void init() { + if (baseFragment == null) { + return; + } if (baseFragment instanceof ChatActivity) { galleryAlbumEntry = MediaController.allMediaAlbumEntry; TLRPC.Chat chat = ((ChatActivity) baseFragment).getCurrentChat(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java index 40ef2f364..106ea2406 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java @@ -830,7 +830,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific protected void onMeasure(int widthSpec, int heightSpec) { ignoreLayout = true; int width = MeasureSpec.getSize(widthSpec); - emojiLayoutManager.setSpanCount(width / AndroidUtilities.dp(AndroidUtilities.isTablet() ? 60 : 45)); + emojiLayoutManager.setSpanCount(Math.max(1, width / AndroidUtilities.dp(AndroidUtilities.isTablet() ? 60 : 45))); ignoreLayout = false; super.onMeasure(widthSpec, heightSpec); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/FragmentContextView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/FragmentContextView.java index bc272ff1b..e0235e1ce 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/FragmentContextView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/FragmentContextView.java @@ -390,7 +390,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent } NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.messagePlayingSpeedChanged); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didStartedCall); - NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didEndedCall); + NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didEndCall); } } @@ -412,7 +412,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent } NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.messagePlayingSpeedChanged); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didStartedCall); - NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didEndedCall); + NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didEndCall); if (additionalContextView != null) { additionalContextView.checkVisibility(); } @@ -441,14 +441,12 @@ public class FragmentContextView extends FrameLayout implements NotificationCent checkLocationString(); } } - } else if (id == NotificationCenter.messagePlayingDidStart || id == NotificationCenter.messagePlayingPlayStateChanged || id == NotificationCenter.messagePlayingDidReset || id == NotificationCenter.didEndedCall) { + } else if (id == NotificationCenter.messagePlayingDidStart || id == NotificationCenter.messagePlayingPlayStateChanged || id == NotificationCenter.messagePlayingDidReset || id == NotificationCenter.didEndCall) { checkPlayer(false); } else if (id == NotificationCenter.didStartedCall) { checkCall(false); } else if (id == NotificationCenter.messagePlayingSpeedChanged) { updatePlaybackButton(); - } else { - checkPlayer(false); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoPaintView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoPaintView.java index 727fa4711..640d21041 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoPaintView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoPaintView.java @@ -18,7 +18,6 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; -import android.view.inputmethod.InputMethodManager; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; @@ -29,7 +28,6 @@ import com.google.android.gms.vision.face.Face; import com.google.android.gms.vision.face.FaceDetector; import org.telegram.messenger.AndroidUtilities; -import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.Bitmaps; import org.telegram.messenger.BuildVars; import org.telegram.messenger.DispatchQueue; @@ -868,9 +866,9 @@ public class PhotoPaintView extends FrameLayout implements EntityView.EntityView setTextDimVisibility(true, textPaintView); textPaintView.beginEditing(); - - InputMethodManager inputMethodManager = (InputMethodManager) ApplicationLoader.applicationContext.getSystemService(Activity.INPUT_METHOD_SERVICE); - inputMethodManager.toggleSoftInputFromWindow(textPaintView.getFocusedView().getWindowToken(), InputMethodManager.SHOW_FORCED, 0); + View view = textPaintView.getFocusedView(); + view.requestFocus(); + AndroidUtilities.showKeyboard(view); } public void closeTextEnter(boolean apply) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PullForegroundDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PullForegroundDrawable.java index 8f283a9ef..a79fa4293 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PullForegroundDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PullForegroundDrawable.java @@ -334,8 +334,8 @@ public class PullForegroundDrawable { Theme.dialogs_archiveAvatarDrawable.setProgress(0f); if (!Theme.dialogs_archiveAvatarDrawableRecolored) { Theme.dialogs_archiveAvatarDrawable.beginApplyLayerColors(); - Theme.dialogs_archiveAvatarDrawable.setLayerColor("Arrow1.**", Theme.getColor(avatarBackgroundColorKey)); - Theme.dialogs_archiveAvatarDrawable.setLayerColor("Arrow2.**", Theme.getColor(avatarBackgroundColorKey)); + Theme.dialogs_archiveAvatarDrawable.setLayerColor("Arrow1.**", Theme.getNonAnimatedColor(avatarBackgroundColorKey)); + Theme.dialogs_archiveAvatarDrawable.setLayerColor("Arrow2.**", Theme.getNonAnimatedColor(avatarBackgroundColorKey)); Theme.dialogs_archiveAvatarDrawable.commitApplyLayerColors(); Theme.dialogs_archiveAvatarDrawableRecolored = true; } @@ -532,7 +532,7 @@ public class PullForegroundDrawable { private void setOutProgress(float value) { outProgress = value; - int color = ColorUtils.blendARGB(Theme.getColor(avatarBackgroundColorKey), Theme.getColor(backgroundActiveColorKey), 1f - outProgress); + int color = ColorUtils.blendARGB(Theme.getNonAnimatedColor(avatarBackgroundColorKey), Theme.getNonAnimatedColor(backgroundActiveColorKey), 1f - outProgress); paintBackgroundAccent.setColor(color); if (changeAvatarColor && isDraw()) { Theme.dialogs_archiveAvatarDrawable.beginApplyLayerColors(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/StickersAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/StickersAlert.java index 00f792a16..8eac17aad 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/StickersAlert.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/StickersAlert.java @@ -809,6 +809,7 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not @Override public void onAnimationEnd(Animator animation) { stickerPreviewLayout.setVisibility(View.GONE); + stickerImageView.setImageDrawable(null); } }); animatorSet.start(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java index 732983c19..9d3b33904 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java @@ -2535,7 +2535,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. dialogInsertFinished = 0; dialogChangeFinished = 0; AndroidUtilities.runOnUIThread(() -> { - if (folderId != 0 && frozenDialogsList.isEmpty()) { + if (folderId != 0 && (frozenDialogsList == null || frozenDialogsList.isEmpty())) { listView.setEmptyView(null); progressView.setVisibility(View.INVISIBLE); finishFragment(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index ae7fe0ff6..971e56ac1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -2421,7 +2421,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa } }); try { - progressDialog.showDelayed(3); + progressDialog.showDelayed(300); } catch (Exception ignore) { } @@ -3255,9 +3255,13 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa openThemeAccentPreview(loadingTheme, loadingThemeWallpaper, loadingThemeInfo); onThemeLoadFinish(); } else { + Theme.ThemeInfo info = loadingThemeInfo; Utilities.globalQueue.postRunnable(() -> { - loadingThemeInfo.createBackground(file, loadingThemeInfo.pathToWallpaper); + info.createBackground(file, info.pathToWallpaper); AndroidUtilities.runOnUIThread(() -> { + if (loadingTheme == null) { + return; + } File locFile = new File(ApplicationLoader.getFilesDirFixed(), "remote" + loadingTheme.id + ".attheme"); Theme.ThemeInfo finalThemeInfo = Theme.applyThemeFile(locFile, loadingTheme.title, loadingTheme, true); if (finalThemeInfo != null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PaymentFormActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PaymentFormActivity.java index 796e68f9b..ff6c54fc6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PaymentFormActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PaymentFormActivity.java @@ -3077,7 +3077,9 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen private void setDonePressed(boolean value) { donePressed = value; swipeBackEnabled = !value; - actionBar.getBackButton().setEnabled(!donePressed); + if (actionBar != null) { + actionBar.getBackButton().setEnabled(!donePressed); + } if (detailSettingsCell[0] != null) { detailSettingsCell[0].setEnabled(!donePressed); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index 197906735..12fde950a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -1821,8 +1821,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private void setScaleToFill() { float bitmapWidth = centerImage.getBitmapWidth(); - float containerWidth = getContainerViewWidth(); float bitmapHeight = centerImage.getBitmapHeight(); + if (bitmapWidth == 0 || bitmapHeight == 0) { + return; + } + float containerWidth = getContainerViewWidth(); float containerHeight = getContainerViewHeight(); float scaleFit = Math.min(containerHeight / bitmapHeight, containerWidth / bitmapWidth); float width = (int) (bitmapWidth * scaleFit); @@ -2002,7 +2005,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat animatingImageView.setTranslationX(animatingImageView.getTranslationX() - getLeftInset()); animationValues[0][2] = animatingImageView.getTranslationX(); } - windowView.requestLayout(); + if (windowView != null) { + windowView.requestLayout(); + } } containerView.setPadding(insets.getSystemWindowInsetLeft(), 0, insets.getSystemWindowInsetRight(), 0); return insets.consumeSystemWindowInsets(); @@ -2669,6 +2674,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat pickerViewSendButton.setBackgroundDrawable(drawable); pickerViewSendButton.setColorFilter(new PorterDuffColorFilter(0xffffffff, PorterDuff.Mode.MULTIPLY)); pickerViewSendButton.setImageResource(R.drawable.attach_send); + pickerViewSendButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogFloatingIcon), PorterDuff.Mode.MULTIPLY)); containerView.addView(pickerViewSendButton, LayoutHelper.createFrame(56, 56, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, 14, 14)); pickerViewSendButton.setContentDescription(LocaleController.getString("Send", R.string.Send)); pickerViewSendButton.setOnClickListener(v -> { @@ -4018,6 +4024,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat Drawable drawable = pickerViewSendButton.getBackground(); Theme.setSelectorDrawableColor(drawable, color, false); Theme.setSelectorDrawableColor(drawable, Theme.getColor(Build.VERSION.SDK_INT >= 21 ? Theme.key_dialogFloatingButtonPressed : Theme.key_dialogFloatingButton), true); + pickerViewSendButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogFloatingIcon), PorterDuff.Mode.MULTIPLY)); } if (checkImageView != null) { checkImageView.setColor(Theme.getColor(Theme.key_dialogFloatingButton), 0xffffffff); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/TooManyCommunitiesActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/TooManyCommunitiesActivity.java index ce1806a5f..6f163dc6a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/TooManyCommunitiesActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/TooManyCommunitiesActivity.java @@ -287,12 +287,8 @@ public class TooManyCommunitiesActivity extends BaseFragment { }).start(); RecyclerListView list = searchViewContainer.getVisibility() == View.VISIBLE ? searchListView : listView; - //ValueAnimator listPaddingAnimator = ValueAnimator.ofFloat(listView.getPaddingBottom(), 0); list.hideSelector(false); -// listPaddingAnimator.addUpdateListener(animation -> { -// float v = (float) animation.getAnimatedValue(); -// -// }); + int last = ((LinearLayoutManager) list.getLayoutManager()).findLastVisibleItemPosition(); if (last == list.getAdapter().getItemCount() - 1 || (last == list.getAdapter().getItemCount() - 2 && list == listView)) { RecyclerView.ViewHolder holder = list.findViewHolderForAdapterPosition(last);