1
0
mirror of https://github.com/NekoX-Dev/NekoX.git synced 2024-12-16 10:29:50 +01:00

Merge remote-tracking branch 'upstream/master'

# Conflicts:
#	TMessagesProj/build.gradle
#	TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java
This commit is contained in:
世界 2020-11-01 01:13:18 +00:00
commit e5d871e999
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
21 changed files with 132 additions and 105 deletions

View File

@ -5,8 +5,8 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-android-extensions'
def verName = "7.2.1-preview04" def verName = "7.2.1-preview05"
def verCode = 96 def verCode = 98
def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json") def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json")

View File

@ -1048,6 +1048,8 @@ public class DownloadController extends BaseController implements NotificationCe
MessageObject messageObject = (MessageObject) delayedMessage.extraHashMap.get(fileName + "_i"); MessageObject messageObject = (MessageObject) delayedMessage.extraHashMap.get(fileName + "_i");
if (messageObject != null && messageObject.isVideo()) { if (messageObject != null && messageObject.isVideo()) {
getMessagesController().sendTyping(dialogId, topMessageId, 5, 0); getMessagesController().sendTyping(dialogId, topMessageId, 5, 0);
} else if (messageObject != null && messageObject.getDocument() != null) {
getMessagesController().sendTyping(dialogId, topMessageId, 3, 0);
} else { } else {
getMessagesController().sendTyping(dialogId, topMessageId, 4, 0); getMessagesController().sendTyping(dialogId, topMessageId, 4, 0);
} }

View File

@ -405,9 +405,11 @@ public class ImageLoader {
@Override @Override
protected void onPostExecute(final String result) { protected void onPostExecute(final String result) {
if (result != null) { if (result != null) {
cacheImage.httpTask = new HttpImageTask(cacheImage, 0, result); imageLoadQueue.postRunnable(() -> {
httpTasks.add(cacheImage.httpTask); cacheImage.httpTask = new HttpImageTask(cacheImage, 0, result);
runHttpTasks(false); httpTasks.add(cacheImage.httpTask);
runHttpTasks(false);
});
} else if (canRetry) { } else if (canRetry) {
artworkLoadError(cacheImage.url); artworkLoadError(cacheImage.url);
} }

View File

@ -261,9 +261,10 @@ public class LocaleController {
"nl", "nn", "no", "sv", "af", "bg", "bn", "ca", "eu", "fur", "fy", "gu", "ha", "is", "ku", "nl", "nn", "no", "sv", "af", "bg", "bn", "ca", "eu", "fur", "fy", "gu", "ha", "is", "ku",
"lb", "ml", "mr", "nah", "ne", "om", "or", "pa", "pap", "ps", "so", "sq", "sw", "ta", "te", "lb", "ml", "mr", "nah", "ne", "om", "or", "pa", "pap", "ps", "so", "sq", "sw", "ta", "te",
"tk", "ur", "zu", "mn", "gsw", "chr", "rm", "pt", "an", "ast"}, new PluralRules_One()); "tk", "ur", "zu", "mn", "gsw", "chr", "rm", "pt", "an", "ast"}, new PluralRules_One());
addRules(new String[]{"cs", "sk", "sr", "hr", "bs"}, new PluralRules_Czech()); addRules(new String[]{"cs", "sk"}, new PluralRules_Czech());
addRules(new String[]{"ff", "fr", "kab"}, new PluralRules_French()); addRules(new String[]{"ff", "fr", "kab"}, new PluralRules_French());
addRules(new String[]{"ru", "uk", "be", "sh"}, new PluralRules_Balkan()); addRules(new String[]{"ru", "uk", "be", "sh"}, new PluralRules_Balkan());
addRules(new String[]{"sr", "hr", "bs"}, new PluralRules_Serbian());
addRules(new String[]{"lv"}, new PluralRules_Latvian()); addRules(new String[]{"lv"}, new PluralRules_Latvian());
addRules(new String[]{"lt"}, new PluralRules_Lithuanian()); addRules(new String[]{"lt"}, new PluralRules_Lithuanian());
addRules(new String[]{"pl"}, new PluralRules_Polish()); addRules(new String[]{"pl"}, new PluralRules_Polish());
@ -2927,6 +2928,20 @@ public class LocaleController {
} }
} }
public static class PluralRules_Serbian extends PluralRules {
public int quantityForNumber(int count) {
int rem100 = count % 100;
int rem10 = count % 10;
if (rem10 == 1 && rem100 != 11) {
return QUANTITY_ONE;
} else if (rem10 >= 2 && rem10 <= 4 && !(rem100 >= 12 && rem100 <= 14)) {
return QUANTITY_FEW;
} else {
return QUANTITY_OTHER;
}
}
}
public static class PluralRules_Arabic extends PluralRules { public static class PluralRules_Arabic extends PluralRules {
public int quantityForNumber(int count) { public int quantityForNumber(int count) {
int rem100 = count % 100; int rem100 = count % 100;

View File

@ -4112,7 +4112,7 @@ public class MessageObject {
lastLineWidth = linesMaxWidth; lastLineWidth = linesMaxWidth;
} }
linesMaxWidthWithLeft = lastLineWidthWithLeft = (int) Math.ceil(lastLine + lastLeft); linesMaxWidthWithLeft = lastLineWidthWithLeft = (int) Math.ceil(linesMaxWidth + Math.max(0, lastLeft));
if (currentBlockLinesCount > 1) { if (currentBlockLinesCount > 1) {
boolean hasNonRTL = false; boolean hasNonRTL = false;
@ -4125,10 +4125,6 @@ public class MessageObject {
lineWidth = 0; lineWidth = 0;
} }
if (lineWidth > maxWidth + 20) {
lineWidth = maxWidth;
}
try { try {
lineLeft = block.textLayout.getLineLeft(n); lineLeft = block.textLayout.getLineLeft(n);
} catch (Exception e) { } catch (Exception e) {
@ -4136,6 +4132,11 @@ public class MessageObject {
lineLeft = 0; lineLeft = 0;
} }
if (lineWidth > maxWidth + 20) {
lineWidth = maxWidth;
lineLeft = 0;
}
if (lineLeft > 0) { if (lineLeft > 0) {
textXOffset = Math.min(textXOffset, lineLeft); textXOffset = Math.min(textXOffset, lineLeft);
block.directionFlags |= 1; block.directionFlags |= 1;

View File

@ -4405,7 +4405,7 @@ public class MessagesController extends BaseController implements NotificationCe
} }
public void deleteDialog(final long did, final int onlyHistory, boolean revoke) { public void deleteDialog(final long did, final int onlyHistory, boolean revoke) {
deleteDialog(did, true, onlyHistory, 0, revoke, null, 0); deleteDialog(did, 1, onlyHistory, 0, revoke, null, 0);
} }
public void setDialogsInTransaction(boolean transaction) { public void setDialogsInTransaction(boolean transaction) {
@ -4415,11 +4415,16 @@ public class MessagesController extends BaseController implements NotificationCe
} }
} }
protected void deleteDialog(final long did, final boolean first, final int onlyHistory, final int max_id, boolean revoke, TLRPC.InputPeer peer, final long taskId) { protected void deleteDialog(long did, int first, int onlyHistory, int max_id, boolean revoke, TLRPC.InputPeer peer, long taskId) {
if (onlyHistory == 2) { if (onlyHistory == 2) {
getMessagesStorage().deleteDialog(did, onlyHistory); getMessagesStorage().deleteDialog(did, onlyHistory);
return; return;
} }
if (first == 1 && max_id == 0) {
TLRPC.InputPeer peerFinal = peer;
getMessagesStorage().getDialogMaxMessageId(did, (param) -> deleteDialog(did, 2, onlyHistory, Math.max(0, param), revoke, peerFinal, taskId));
return;
}
if (onlyHistory == 0 || onlyHistory == 3) { if (onlyHistory == 0 || onlyHistory == 3) {
getMediaDataController().uninstallShortcut(did); getMediaDataController().uninstallShortcut(did);
} }
@ -4427,15 +4432,8 @@ public class MessagesController extends BaseController implements NotificationCe
int high_id = (int) (did >> 32); int high_id = (int) (did >> 32);
int max_id_delete = max_id; int max_id_delete = max_id;
if (first) { if (first != 0) {
boolean isPromoDialog = false; boolean isPromoDialog = false;
boolean emptyMax = max_id_delete == 0;
if (emptyMax) {
int max = getMessagesStorage().getDialogMaxMessageId(did);
if (max > 0) {
max_id_delete = Math.max(max, max_id_delete);
}
}
getMessagesStorage().deleteDialog(did, onlyHistory); getMessagesStorage().deleteDialog(did, onlyHistory);
TLRPC.Dialog dialog = dialogs_dict.get(did); TLRPC.Dialog dialog = dialogs_dict.get(did);
if (onlyHistory == 0 || onlyHistory == 3) { if (onlyHistory == 0 || onlyHistory == 3) {
@ -4445,7 +4443,7 @@ public class MessagesController extends BaseController implements NotificationCe
getMediaDataController().cleanDraft(did, 0, false); getMediaDataController().cleanDraft(did, 0, false);
} }
if (dialog != null) { if (dialog != null) {
if (emptyMax) { if (first == 2) {
max_id_delete = Math.max(0, dialog.top_message); max_id_delete = Math.max(0, dialog.top_message);
max_id_delete = Math.max(max_id_delete, dialog.read_inbox_max_id); max_id_delete = Math.max(max_id_delete, dialog.read_inbox_max_id);
max_id_delete = Math.max(max_id_delete, dialog.read_outbox_max_id); max_id_delete = Math.max(max_id_delete, dialog.read_outbox_max_id);
@ -4525,7 +4523,7 @@ public class MessagesController extends BaseController implements NotificationCe
} }
} }
} }
if (emptyMax) { if (first == 2) {
Integer max = dialogs_read_inbox_max.get(did); Integer max = dialogs_read_inbox_max.get(did);
if (max != null) { if (max != null) {
max_id_delete = Math.max(max, max_id_delete); max_id_delete = Math.max(max, max_id_delete);
@ -4572,7 +4570,7 @@ public class MessagesController extends BaseController implements NotificationCe
data = new NativeByteBuffer(4 + 8 + 4 + 4 + 4 + 4 + peer.getObjectSize()); data = new NativeByteBuffer(4 + 8 + 4 + 4 + 4 + 4 + peer.getObjectSize());
data.writeInt32(13); data.writeInt32(13);
data.writeInt64(did); data.writeInt64(did);
data.writeBool(first); data.writeBool(first != 0);
data.writeInt32(onlyHistory); data.writeInt32(onlyHistory);
data.writeInt32(max_id_delete); data.writeInt32(max_id_delete);
data.writeBool(revoke); data.writeBool(revoke);
@ -4620,7 +4618,7 @@ public class MessagesController extends BaseController implements NotificationCe
if (error == null) { if (error == null) {
TLRPC.TL_messages_affectedHistory res = (TLRPC.TL_messages_affectedHistory) response; TLRPC.TL_messages_affectedHistory res = (TLRPC.TL_messages_affectedHistory) response;
if (res.offset > 0) { if (res.offset > 0) {
deleteDialog(did, false, onlyHistory, max_id_delete_final, revoke, peerFinal, 0); deleteDialog(did, 0, onlyHistory, max_id_delete_final, revoke, peerFinal, 0);
} }
processNewDifferenceParams(-1, res.pts, -1, res.pts_count); processNewDifferenceParams(-1, res.pts, -1, res.pts_count);
getMessagesStorage().onDeleteQueryComplete(did); getMessagesStorage().onDeleteQueryComplete(did);

View File

@ -1233,7 +1233,7 @@ public class MessagesStorage extends BaseController {
final int maxIdDelete = data.readInt32(false); final int maxIdDelete = data.readInt32(false);
final boolean revoke = data.readBool(false); final boolean revoke = data.readBool(false);
TLRPC.InputPeer inputPeer = TLRPC.InputPeer.TLdeserialize(data, data.readInt32(false), false); TLRPC.InputPeer inputPeer = TLRPC.InputPeer.TLdeserialize(data, data.readInt32(false), false);
AndroidUtilities.runOnUIThread(() -> getMessagesController().deleteDialog(did, first, onlyHistory, maxIdDelete, revoke, inputPeer, taskId)); AndroidUtilities.runOnUIThread(() -> getMessagesController().deleteDialog(did, first ? 1 : 0, onlyHistory, maxIdDelete, revoke, inputPeer, taskId));
break; break;
} }
case 15: { case 15: {
@ -10889,11 +10889,10 @@ public class MessagesStorage extends BaseController {
}); });
} }
public int getDialogMaxMessageId(final long dialog_id) { public void getDialogMaxMessageId(final long dialog_id, IntCallback callback) {
final CountDownLatch countDownLatch = new CountDownLatch(1);
final Integer[] max = new Integer[]{0};
storageQueue.postRunnable(() -> { storageQueue.postRunnable(() -> {
SQLiteCursor cursor = null; SQLiteCursor cursor = null;
int[] max = new int[1];
try { try {
cursor = database.queryFinalized("SELECT MAX(mid) FROM messages WHERE uid = " + dialog_id); cursor = database.queryFinalized("SELECT MAX(mid) FROM messages WHERE uid = " + dialog_id);
if (cursor.next()) { if (cursor.next()) {
@ -10906,14 +10905,8 @@ public class MessagesStorage extends BaseController {
cursor.dispose(); cursor.dispose();
} }
} }
countDownLatch.countDown(); AndroidUtilities.runOnUIThread(() -> callback.run(max[0]));
}); });
try {
countDownLatch.await();
} catch (Exception e) {
FileLog.e(e);
}
return max[0];
} }
public int getDialogReadMax(final boolean outbox, final long dialog_id) { public int getDialogReadMax(final boolean outbox, final long dialog_id) {

View File

@ -280,7 +280,7 @@ public class NotificationCenter {
public int setAnimationInProgress(int oldIndex, int[] allowedNotifications, boolean stopHeavyOperations) { public int setAnimationInProgress(int oldIndex, int[] allowedNotifications, boolean stopHeavyOperations) {
onAnimationFinish(oldIndex); onAnimationFinish(oldIndex);
if (heavyOperationsCounter.isEmpty() && stopHeavyOperations) { if (heavyOperationsCounter.isEmpty() && stopHeavyOperations) {
NotificationCenter.getGlobalInstance().postNotificationName(stopAllHeavyOperations, 512); getGlobalInstance().postNotificationName(stopAllHeavyOperations, 512);
} }
animationInProgressCount++; animationInProgressCount++;

View File

@ -871,7 +871,9 @@ public boolean retriedToSend;
message.messageObjects.remove(index); message.messageObjects.remove(index);
message.messages.remove(index); message.messages.remove(index);
message.originalPaths.remove(index); message.originalPaths.remove(index);
message.parentObjects.remove(index); if (!message.parentObjects.isEmpty()) {
message.parentObjects.remove(index);
}
if (message.sendRequest != null) { if (message.sendRequest != null) {
TLRPC.TL_messages_sendMultiMedia request = (TLRPC.TL_messages_sendMultiMedia) message.sendRequest; TLRPC.TL_messages_sendMultiMedia request = (TLRPC.TL_messages_sendMultiMedia) message.sendRequest;
request.multi_media.remove(index); request.multi_media.remove(index);
@ -5444,7 +5446,7 @@ public boolean retriedToSend;
docType[0] = 0; docType[0] = 0;
} }
} }
if (groupId != null) { if (!isEncrypted && groupId != null) {
if (docType != null && prevType != null && prevType != docType[0]) { if (docType != null && prevType != null && prevType != docType[0]) {
finishGroup(accountInstance, groupId[0], scheduleDate); finishGroup(accountInstance, groupId[0], scheduleDate);
groupId[0] = Utilities.random.nextLong(); groupId[0] = Utilities.random.nextLong();
@ -5504,7 +5506,7 @@ public boolean retriedToSend;
enryptedLayer = AndroidUtilities.getPeerLayerVersion(encryptedChat.layer); enryptedLayer = AndroidUtilities.getPeerLayerVersion(encryptedChat.layer);
} }
} }
if ((!isEncrypted || enryptedLayer >= 73) && count > 1 && mediaCount % 10 == 0) { if (!isEncrypted && count > 1 && mediaCount % 10 == 0) {
groupId = Utilities.random.nextLong(); groupId = Utilities.random.nextLong();
mediaCount = 0; mediaCount = 0;
} }

View File

@ -278,6 +278,12 @@ public class BaseFragment {
return false; return false;
} }
protected void resumeDelayedFragmentAnimation() {
if (parentLayout != null) {
parentLayout.resumeDelayedFragmentAnimation();
}
}
public void onResume() { public void onResume() {
isPaused = false; isPaused = false;
} }

View File

@ -3415,7 +3415,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
try { try {
int width = (int) Math.ceil(Theme.chat_replyNamePaint.measureText(site_name) + 1); int width = (int) Math.ceil(Theme.chat_replyNamePaint.measureText(site_name) + 1);
siteNameLayout = new StaticLayout(site_name, Theme.chat_replyNamePaint, Math.min(width, linkPreviewMaxWidth), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); siteNameLayout = new StaticLayout(site_name, Theme.chat_replyNamePaint, Math.min(width, linkPreviewMaxWidth), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
siteNameRtl = siteNameLayout.getLineLeft(0) != 0; siteNameRtl = Math.max(siteNameLayout.getLineLeft(0), 0) != 0;
int height = siteNameLayout.getLineBottom(siteNameLayout.getLineCount() - 1); int height = siteNameLayout.getLineBottom(siteNameLayout.getLineCount() - 1);
linkPreviewHeight += height; linkPreviewHeight += height;
totalHeight += height; totalHeight += height;
@ -3449,7 +3449,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
totalHeight += height; totalHeight += height;
boolean checkForRtl = true; boolean checkForRtl = true;
for (int a = 0; a < titleLayout.getLineCount(); a++) { for (int a = 0; a < titleLayout.getLineCount(); a++) {
int lineLeft = (int) titleLayout.getLineLeft(a); int lineLeft = (int) Math.max(0, titleLayout.getLineLeft(a));
if (lineLeft != 0) { if (lineLeft != 0) {
titleIsRTL = true; titleIsRTL = true;
} }
@ -3498,7 +3498,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
int height = authorLayout.getLineBottom(authorLayout.getLineCount() - 1); int height = authorLayout.getLineBottom(authorLayout.getLineCount() - 1);
linkPreviewHeight += height; linkPreviewHeight += height;
totalHeight += height; totalHeight += height;
int lineLeft = (int) authorLayout.getLineLeft(0); int lineLeft = (int) Math.max(authorLayout.getLineLeft(0), 0);
authorX = -lineLeft; authorX = -lineLeft;
int width; int width;
if (lineLeft != 0) { if (lineLeft != 0) {
@ -3537,7 +3537,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
boolean hasRTL = false; boolean hasRTL = false;
for (int a = 0; a < descriptionLayout.getLineCount(); a++) { for (int a = 0; a < descriptionLayout.getLineCount(); a++) {
int lineLeft = (int) Math.ceil(descriptionLayout.getLineLeft(a)); int lineLeft = (int) Math.ceil(descriptionLayout.getLineLeft(a));
if (lineLeft != 0) { if (lineLeft > 0) {
hasRTL = true; hasRTL = true;
if (descriptionX == 0) { if (descriptionX == 0) {
descriptionX = -lineLeft; descriptionX = -lineLeft;
@ -3555,7 +3555,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} }
int width; int width;
if (lineLeft != 0) { if (lineLeft > 0) {
width = textWidth - lineLeft; width = textWidth - lineLeft;
} else { } else {
if (hasRTL) { if (hasRTL) {
@ -4254,7 +4254,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
boolean titleRtl = false; boolean titleRtl = false;
if (titleLayout != null) { if (titleLayout != null) {
for (int a = 0, N = titleLayout.getLineCount(); a < N; a++) { for (int a = 0, N = titleLayout.getLineCount(); a < N; a++) {
if (titleLayout.getLineLeft(a) != 0) { if (titleLayout.getLineLeft(a) > 0) {
titleRtl = true; titleRtl = true;
break; break;
} }
@ -12728,7 +12728,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} }
public float getNonAnimationTranslationX(boolean update) { public float getNonAnimationTranslationX(boolean update) {
if (!currentMessageObject.isOutOwner()) { if (currentMessageObject != null && !currentMessageObject.isOutOwner()) {
if (update && (checkBoxVisible || checkBoxAnimationInProgress)) { if (update && (checkBoxVisible || checkBoxAnimationInProgress)) {
Interpolator interpolator = checkBoxVisible ? CubicBezierInterpolator.EASE_OUT : CubicBezierInterpolator.EASE_IN; Interpolator interpolator = checkBoxVisible ? CubicBezierInterpolator.EASE_OUT : CubicBezierInterpolator.EASE_IN;
checkBoxTranslation = (int) Math.ceil(interpolator.getInterpolation(checkBoxAnimationProgress) * AndroidUtilities.dp(35)); checkBoxTranslation = (int) Math.ceil(interpolator.getInterpolation(checkBoxAnimationProgress) * AndroidUtilities.dp(35));

View File

@ -1712,7 +1712,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
@Override @Override
public void onTransitionAnimationStart(boolean isOpen, boolean backward) { public void onTransitionAnimationStart(boolean isOpen, boolean backward) {
if (isOpen) { if (isOpen) {
allowAnimationIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(allowAnimationIndex, new int[]{NotificationCenter.chatInfoDidLoad, NotificationCenter.dialogsNeedReload, allowAnimationIndex = getNotificationCenter().setAnimationInProgress(allowAnimationIndex, new int[]{NotificationCenter.chatInfoDidLoad, NotificationCenter.dialogsNeedReload,
NotificationCenter.closeChats, NotificationCenter.messagesDidLoad, NotificationCenter.botKeyboardDidLoad/*, NotificationCenter.botInfoDidLoad*/}); NotificationCenter.closeChats, NotificationCenter.messagesDidLoad, NotificationCenter.botKeyboardDidLoad/*, NotificationCenter.botInfoDidLoad*/});
openAnimationEnded = false; openAnimationEnded = false;
} }
@ -1721,7 +1721,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
@Override @Override
public void onTransitionAnimationEnd(boolean isOpen, boolean backward) { public void onTransitionAnimationEnd(boolean isOpen, boolean backward) {
if (isOpen) { if (isOpen) {
NotificationCenter.getInstance(currentAccount).onAnimationFinish(allowAnimationIndex); getNotificationCenter().onAnimationFinish(allowAnimationIndex);
openAnimationEnded = true; openAnimationEnded = true;
} }
} }

View File

@ -516,6 +516,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private boolean openAnimationEnded; private boolean openAnimationEnded;
private boolean fragmentOpened; private boolean fragmentOpened;
private boolean fragmentBeginToShow;
private long openAnimationStartTime; private long openAnimationStartTime;
private boolean scrollToTopOnResume; private boolean scrollToTopOnResume;
@ -662,6 +663,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private long activityResumeTime; private long activityResumeTime;
private int transitionAnimationIndex; private int transitionAnimationIndex;
private int scrollAnimationIndex;
private final static int[] allowedNotificationsDuringChatListAnimations = new int[]{ private final static int[] allowedNotificationsDuringChatListAnimations = new int[]{
NotificationCenter.messagesRead, NotificationCenter.messagesRead,
NotificationCenter.threadMessagesRead, NotificationCenter.threadMessagesRead,
@ -1525,6 +1527,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (chatAttachAlert != null) { if (chatAttachAlert != null) {
chatAttachAlert.dismissInternal(); chatAttachAlert.dismissInternal();
} }
getNotificationCenter().onAnimationFinish(transitionAnimationIndex);
getNotificationCenter().onAnimationFinish(scrollAnimationIndex);
hideUndoViews(); hideUndoViews();
if (chatInviteRunnable != null) { if (chatInviteRunnable != null) {
AndroidUtilities.cancelRunOnUIThread(chatInviteRunnable); AndroidUtilities.cancelRunOnUIThread(chatInviteRunnable);
@ -4199,13 +4203,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (MessagesController.getGlobalMainSettings().getBoolean("view_animations", true)) { if (MessagesController.getGlobalMainSettings().getBoolean("view_animations", true)) {
chatListItemAniamtor = new ChatListItemAnimator(this, chatListView) { chatListItemAniamtor = new ChatListItemAnimator(this, chatListView) {
int index = -1;
Runnable finishRunnable; Runnable finishRunnable;
@Override @Override
public void onAnimationStart() { public void onAnimationStart() {
if (index == -1) { if (scrollAnimationIndex == -1) {
index = getNotificationCenter().setAnimationInProgress(index, allowedNotificationsDuringChatListAnimations, false); scrollAnimationIndex = getNotificationCenter().setAnimationInProgress(scrollAnimationIndex, allowedNotificationsDuringChatListAnimations, false);
} }
if (finishRunnable != null) { if (finishRunnable != null) {
AndroidUtilities.cancelRunOnUIThread(finishRunnable); AndroidUtilities.cancelRunOnUIThread(finishRunnable);
@ -4227,9 +4230,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
scrollToMessageId(nextScrollToMessageId, nextScrollFromMessageId, nextScrollSelect, nextScrollLoadIndex, nextScrollForce); scrollToMessageId(nextScrollToMessageId, nextScrollFromMessageId, nextScrollSelect, nextScrollLoadIndex, nextScrollForce);
nextScrollToMessageId = 0; nextScrollToMessageId = 0;
} }
if (index != -1) { if (scrollAnimationIndex != -1) {
getNotificationCenter().onAnimationFinish(index); getNotificationCenter().onAnimationFinish(scrollAnimationIndex);
index = -1; scrollAnimationIndex = -1;
} }
if (BuildVars.LOGS_ENABLED) { if (BuildVars.LOGS_ENABLED) {
FileLog.d("chatItemAnimator enable notifications"); FileLog.d("chatItemAnimator enable notifications");
@ -4245,9 +4248,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
AndroidUtilities.cancelRunOnUIThread(finishRunnable); AndroidUtilities.cancelRunOnUIThread(finishRunnable);
} }
AndroidUtilities.runOnUIThread(finishRunnable = () -> { AndroidUtilities.runOnUIThread(finishRunnable = () -> {
if (index != -1) { if (scrollAnimationIndex != -1) {
getNotificationCenter().onAnimationFinish(index); getNotificationCenter().onAnimationFinish(scrollAnimationIndex);
index = -1; scrollAnimationIndex = -1;
} }
if (BuildVars.LOGS_ENABLED) { if (BuildVars.LOGS_ENABLED) {
FileLog.d("chatItemAnimator enable notifications"); FileLog.d("chatItemAnimator enable notifications");
@ -11502,11 +11505,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else { } else {
doNotRemoveLoadIndex = false; doNotRemoveLoadIndex = false;
} }
if (!doNotRemoveLoadIndex && !openAnimationEnded) { if (!doNotRemoveLoadIndex && !fragmentBeginToShow && !paused) {
int[] alowedNotifications = new int[]{NotificationCenter.chatInfoDidLoad, NotificationCenter.dialogsNeedReload, NotificationCenter.scheduledMessagesUpdated, int[] alowedNotifications = new int[]{NotificationCenter.chatInfoDidLoad, NotificationCenter.dialogsNeedReload, NotificationCenter.scheduledMessagesUpdated,
NotificationCenter.closeChats, NotificationCenter.botKeyboardDidLoad, NotificationCenter.userInfoDidLoad, NotificationCenter.pinnedInfoDidLoad, NotificationCenter.needDeleteDialog/*, NotificationCenter.botInfoDidLoad*/}; NotificationCenter.closeChats, NotificationCenter.botKeyboardDidLoad, NotificationCenter.userInfoDidLoad, NotificationCenter.pinnedInfoDidLoad, NotificationCenter.needDeleteDialog/*, NotificationCenter.botInfoDidLoad*/};
if (transitionAnimationIndex == 0) { if (transitionAnimationIndex == 0) {
transitionAnimationIndex = getNotificationCenter().setAnimationInProgress(transitionAnimationIndex, alowedNotifications); transitionAnimationIndex = getNotificationCenter().setAnimationInProgress(transitionAnimationIndex, alowedNotifications);
AndroidUtilities.runOnUIThread(() -> getNotificationCenter().onAnimationFinish(transitionAnimationIndex), 800);
} else { } else {
getNotificationCenter().updateAllowedNotifications(transitionAnimationIndex, alowedNotifications); getNotificationCenter().updateAllowedNotifications(transitionAnimationIndex, alowedNotifications);
} }
@ -11715,9 +11719,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
firstLoading = false; firstLoading = false;
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
getNotificationCenter().runDelayedNotifications(); getNotificationCenter().runDelayedNotifications();
if (parentLayout != null) { resumeDelayedFragmentAnimation();
parentLayout.resumeDelayedFragmentAnimation();
}
}); });
} }
@ -15294,6 +15296,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public void onTransitionAnimationStart(boolean isOpen, boolean backward) { public void onTransitionAnimationStart(boolean isOpen, boolean backward) {
int[] alowedNotifications = null; int[] alowedNotifications = null;
if (isOpen) { if (isOpen) {
fragmentBeginToShow = true;
if (transitionAnimationIndex == 0) { if (transitionAnimationIndex == 0) {
alowedNotifications = new int[]{ alowedNotifications = new int[]{
NotificationCenter.dialogsNeedReload, NotificationCenter.closeChats, NotificationCenter.dialogsNeedReload, NotificationCenter.closeChats,

View File

@ -1905,9 +1905,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
req.offset = offset; req.offset = offset;
req.limit = count; req.limit = count;
int reqId = getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { int reqId = getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (parentLayout != null) { resumeDelayedFragmentAnimation();
parentLayout.resumeDelayedFragmentAnimation();
}
if (error == null) { if (error == null) {
TLRPC.TL_channels_channelParticipants res = (TLRPC.TL_channels_channelParticipants) response; TLRPC.TL_channels_channelParticipants res = (TLRPC.TL_channels_channelParticipants) response;
if (type == TYPE_ADMIN) { if (type == TYPE_ADMIN) {

View File

@ -3611,13 +3611,13 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
if (currentTopViewAnimation != null && currentTopViewAnimation.equals(animation)) { if (currentTopViewAnimation != null && currentTopViewAnimation.equals(animation)) {
currentTopViewAnimation = null; currentTopViewAnimation = null;
} }
NotificationCenter.getGlobalInstance().onAnimationFinish(notificationsIndex); NotificationCenter.getInstance(currentAccount).onAnimationFinish(notificationsIndex);
} }
}); });
currentTopViewAnimation.setDuration(250); currentTopViewAnimation.setDuration(250);
currentTopViewAnimation.setInterpolator(CubicBezierInterpolator.DEFAULT); currentTopViewAnimation.setInterpolator(CubicBezierInterpolator.DEFAULT);
currentTopViewAnimation.start(); currentTopViewAnimation.start();
notificationsIndex = NotificationCenter.getGlobalInstance().setAnimationInProgress(notificationsIndex, null); notificationsIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(notificationsIndex, null);
} else { } else {
topViewEnterProgress = 1f; topViewEnterProgress = 1f;
topView.setTranslationY(0); topView.setTranslationY(0);
@ -3917,6 +3917,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
public void setDialogId(long id, int account) { public void setDialogId(long id, int account) {
dialog_id = id; dialog_id = id;
if (currentAccount != account) { if (currentAccount != account) {
NotificationCenter.getInstance(currentAccount).onAnimationFinish(notificationsIndex);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.recordStarted); NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.recordStarted);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.recordStartError); NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.recordStartError);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.recordStopped); NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.recordStopped);
@ -6866,12 +6867,12 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
if (delegate != null) { if (delegate != null) {
delegate.bottomPanelTranslationYChanged(0); delegate.bottomPanelTranslationYChanged(0);
} }
NotificationCenter.getGlobalInstance().onAnimationFinish(notificationsIndex); NotificationCenter.getInstance(currentAccount).onAnimationFinish(notificationsIndex);
requestLayout(); requestLayout();
} }
}); });
panelAnimation.start(); panelAnimation.start();
notificationsIndex = NotificationCenter.getGlobalInstance().setAnimationInProgress(notificationsIndex, null); notificationsIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(notificationsIndex, null);
requestLayout(); requestLayout();
} }
} }
@ -6909,11 +6910,11 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
if (delegate != null) { if (delegate != null) {
delegate.bottomPanelTranslationYChanged(0); delegate.bottomPanelTranslationYChanged(0);
} }
NotificationCenter.getInstance(UserConfig.selectedAccount).onAnimationFinish(notificationsIndex); NotificationCenter.getInstance(currentAccount).onAnimationFinish(notificationsIndex);
requestLayout(); requestLayout();
} }
}); });
notificationsIndex = NotificationCenter.getInstance(UserConfig.selectedAccount).setAnimationInProgress(notificationsIndex, null); notificationsIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(notificationsIndex, null);
panelAnimation.start(); panelAnimation.start();
requestLayout(); requestLayout();
} else { } else {
@ -6953,14 +6954,14 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
panelAnimation = null; panelAnimation = null;
botKeyboardView.setTranslationY(0); botKeyboardView.setTranslationY(0);
botKeyboardView.setVisibility(GONE); botKeyboardView.setVisibility(GONE);
NotificationCenter.getInstance(UserConfig.selectedAccount).onAnimationFinish(notificationsIndex); NotificationCenter.getInstance(currentAccount).onAnimationFinish(notificationsIndex);
if (delegate != null) { if (delegate != null) {
delegate.bottomPanelTranslationYChanged(0); delegate.bottomPanelTranslationYChanged(0);
} }
requestLayout(); requestLayout();
} }
}); });
notificationsIndex = NotificationCenter.getInstance(UserConfig.selectedAccount).setAnimationInProgress(notificationsIndex, null); notificationsIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(notificationsIndex, null);
panelAnimation.start(); panelAnimation.start();
requestLayout(); requestLayout();
} else { } else {
@ -7242,11 +7243,11 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
delegate.bottomPanelTranslationYChanged(0); delegate.bottomPanelTranslationYChanged(0);
} }
requestLayout(); requestLayout();
NotificationCenter.getGlobalInstance().onAnimationFinish(notificationsIndex); NotificationCenter.getInstance(currentAccount).onAnimationFinish(notificationsIndex);
} }
}); });
panelAnimation.start(); panelAnimation.start();
notificationsIndex = NotificationCenter.getGlobalInstance().setAnimationInProgress(notificationsIndex, null); notificationsIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(notificationsIndex, null);
requestLayout(); requestLayout();
} }
} }
@ -7627,12 +7628,12 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
stickersExpansionAnim = null; stickersExpansionAnim = null;
emojiView.setLayerType(LAYER_TYPE_NONE, null); emojiView.setLayerType(LAYER_TYPE_NONE, null);
NotificationCenter.getGlobalInstance().onAnimationFinish(notificationsIndex); NotificationCenter.getInstance(currentAccount).onAnimationFinish(notificationsIndex);
} }
}); });
stickersExpansionAnim = anims; stickersExpansionAnim = anims;
emojiView.setLayerType(LAYER_TYPE_HARDWARE, null); emojiView.setLayerType(LAYER_TYPE_HARDWARE, null);
notificationsIndex = NotificationCenter.getGlobalInstance().setAnimationInProgress(notificationsIndex, null); notificationsIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(notificationsIndex, null);
stickersExpansionProgress = 0f; stickersExpansionProgress = 0f;
sizeNotifierLayout.invalidate(); sizeNotifierLayout.invalidate();
anims.start(); anims.start();
@ -7675,14 +7676,14 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
if (keyboardVisible && isPopupShowing()) { if (keyboardVisible && isPopupShowing()) {
showPopup(0, currentPopupContentType); showPopup(0, currentPopupContentType);
} }
NotificationCenter.getGlobalInstance().onAnimationFinish(notificationsIndex); NotificationCenter.getInstance(currentAccount).onAnimationFinish(notificationsIndex);
} }
}); });
stickersExpansionProgress = 1f; stickersExpansionProgress = 1f;
sizeNotifierLayout.invalidate(); sizeNotifierLayout.invalidate();
stickersExpansionAnim = anims; stickersExpansionAnim = anims;
emojiView.setLayerType(LAYER_TYPE_HARDWARE, null); emojiView.setLayerType(LAYER_TYPE_HARDWARE, null);
notificationsIndex = NotificationCenter.getGlobalInstance().setAnimationInProgress(notificationsIndex, null); notificationsIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(notificationsIndex, null);
anims.start(); anims.start();
} else { } else {
stickersExpansionProgress = 0; stickersExpansionProgress = 0;

View File

@ -79,6 +79,8 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
private boolean isMusic; private boolean isMusic;
private boolean supportsCalls = true; private boolean supportsCalls = true;
private int account = UserConfig.selectedAccount;
private boolean isLocation; private boolean isLocation;
private FragmentContextViewDelegate delegate; private FragmentContextViewDelegate delegate;
@ -715,7 +717,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
animatorSet.addListener(new AnimatorListenerAdapter() { animatorSet.addListener(new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
NotificationCenter.getInstance(UserConfig.selectedAccount).onAnimationFinish(animationIndex); NotificationCenter.getInstance(account).onAnimationFinish(animationIndex);
if (animatorSet != null && animatorSet.equals(animation)) { if (animatorSet != null && animatorSet.equals(animation)) {
setVisibility(GONE); setVisibility(GONE);
if (delegate != null) { if (delegate != null) {
@ -726,7 +728,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
} }
}); });
animatorSet.start(); animatorSet.start();
animationIndex = NotificationCenter.getInstance(UserConfig.selectedAccount).setAnimationInProgress(animationIndex, null); animationIndex = NotificationCenter.getInstance(account).setAnimationInProgress(animationIndex, null);
} }
} }
} else { } else {
@ -765,7 +767,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
animatorSet.addListener(new AnimatorListenerAdapter() { animatorSet.addListener(new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
NotificationCenter.getInstance(UserConfig.selectedAccount).onAnimationFinish(animationIndex); NotificationCenter.getInstance(account).onAnimationFinish(animationIndex);
if (animatorSet != null && animatorSet.equals(animation)) { if (animatorSet != null && animatorSet.equals(animation)) {
if (delegate != null) { if (delegate != null) {
delegate.onAnimation(false, true); delegate.onAnimation(false, true);
@ -775,7 +777,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent
} }
}); });
animatorSet.start(); animatorSet.start();
animationIndex = NotificationCenter.getInstance(UserConfig.selectedAccount).setAnimationInProgress(animationIndex, null); animationIndex = NotificationCenter.getInstance(account).setAnimationInProgress(animationIndex, null);
} }
visible = true; visible = true;
setVisibility(VISIBLE); setVisibility(VISIBLE);

View File

@ -102,6 +102,8 @@ public class VoIPPiPView implements VoIPBaseService.StateListener, NotificationC
long startTime; long startTime;
int animationIndex = -1; int animationIndex = -1;
private int currentAccount;
Runnable collapseRunnable = new Runnable() { Runnable collapseRunnable = new Runnable() {
@Override @Override
public void run() { public void run() {
@ -134,7 +136,7 @@ public class VoIPPiPView implements VoIPBaseService.StateListener, NotificationC
} }
}; };
public static void show(Activity activity, int parentWidth, int parentHeight, int animationType) { public static void show(Activity activity, int account, int parentWidth, int parentHeight, int animationType) {
if (instance != null || VideoCameraCapturer.eglBase == null) { if (instance != null || VideoCameraCapturer.eglBase == null) {
return; return;
} }
@ -142,6 +144,7 @@ public class VoIPPiPView implements VoIPBaseService.StateListener, NotificationC
instance = new VoIPPiPView(activity, parentWidth, parentHeight, false); instance = new VoIPPiPView(activity, parentWidth, parentHeight, false);
WindowManager wm = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE); WindowManager wm = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE);
instance.currentAccount = account;
instance.windowManager = wm; instance.windowManager = wm;
instance.windowLayoutParams = windowLayoutParams; instance.windowLayoutParams = windowLayoutParams;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("voippipconfig", Context.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("voippipconfig", Context.MODE_PRIVATE);
@ -334,7 +337,7 @@ public class VoIPPiPView implements VoIPBaseService.StateListener, NotificationC
enlargeIcon.setOnClickListener((v) -> { enlargeIcon.setOnClickListener((v) -> {
if (context instanceof LaunchActivity && !ApplicationLoader.mainInterfacePaused) { if (context instanceof LaunchActivity && !ApplicationLoader.mainInterfacePaused) {
VoIPFragment.show((Activity) context); VoIPFragment.show((Activity) context, currentAccount);
} else if (context instanceof LaunchActivity) { } else if (context instanceof LaunchActivity) {
Intent intent = new Intent(context, LaunchActivity.class); Intent intent = new Intent(context, LaunchActivity.class);
intent.setAction("voip"); intent.setAction("voip");
@ -588,7 +591,7 @@ public class VoIPPiPView implements VoIPBaseService.StateListener, NotificationC
if (event.getAction() == MotionEvent.ACTION_UP && !moving && System.currentTimeMillis() - startTime < 150) { if (event.getAction() == MotionEvent.ACTION_UP && !moving && System.currentTimeMillis() - startTime < 150) {
Context context = getContext(); Context context = getContext();
if (context instanceof LaunchActivity && !ApplicationLoader.mainInterfacePaused) { if (context instanceof LaunchActivity && !ApplicationLoader.mainInterfacePaused) {
VoIPFragment.show((Activity) context); VoIPFragment.show((Activity) context, currentAccount);
} else if (context instanceof LaunchActivity) { } else if (context instanceof LaunchActivity) {
Intent intent = new Intent(context, LaunchActivity.class); Intent intent = new Intent(context, LaunchActivity.class);
intent.setAction("voip"); intent.setAction("voip");

View File

@ -241,7 +241,6 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
NotificationCenter.getInstance(currentAccount).onAnimationFinish(animationIndex); NotificationCenter.getInstance(currentAccount).onAnimationFinish(animationIndex);
requestLayout(); requestLayout();
super.onAnimationEnd(animation);
} }
}); });
animationIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(animationIndex, null); animationIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(animationIndex, null);

View File

@ -2377,7 +2377,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} }
if (isVoipIntent) { if (isVoipIntent) {
VoIPFragment.show(this); VoIPFragment.show(this, intentAccount[0]);
} }
intent.setAction(null); intent.setAction(null);

View File

@ -1448,7 +1448,7 @@ public class ThemePreviewActivity extends BaseFragment implements DownloadContro
public int getDefaultColor(int num) { public int getDefaultColor(int num) {
if (colorType == 3 && applyingTheme.firstAccentIsDefault && num == 0) { if (colorType == 3 && applyingTheme.firstAccentIsDefault && num == 0) {
Theme.ThemeAccent accent = applyingTheme.themeAccentsMap.get(Theme.DEFALT_THEME_ACCENT_ID); Theme.ThemeAccent accent = applyingTheme.themeAccentsMap.get(Theme.DEFALT_THEME_ACCENT_ID);
return accent.myMessagesAccentColor; return accent != null ? accent.myMessagesAccentColor : 0;
} }
return 0; return 0;
} }

View File

@ -99,6 +99,8 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
private final static int STATE_FULLSCREEN = 1; private final static int STATE_FULLSCREEN = 1;
private final static int STATE_FLOATING = 2; private final static int STATE_FLOATING = 2;
private int currentAccount;
Activity activity; Activity activity;
TLRPC.User currentUser; TLRPC.User currentUser;
@ -205,12 +207,11 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
private boolean screenWasWakeup; private boolean screenWasWakeup;
private boolean isVideoCall; private boolean isVideoCall;
public static void show(Activity activity) { public static void show(Activity activity, int account) {
show(activity, false); show(activity, false, account);
} }
public static void show(Activity activity, boolean overlay, int account) {
public static void show(Activity activity, boolean overlay) {
if (instance != null && instance.windowView.getParent() == null) { if (instance != null && instance.windowView.getParent() == null) {
if (instance != null) { if (instance != null) {
instance.callingUserTextureView.renderer.release(); instance.callingUserTextureView.renderer.release();
@ -229,6 +230,7 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
} }
VoIPFragment fragment = new VoIPFragment(); VoIPFragment fragment = new VoIPFragment();
fragment.activity = activity; fragment.activity = activity;
fragment.currentAccount = account;
instance = fragment; instance = fragment;
VoIPWindowView windowView = new VoIPWindowView(activity, !transitionFromPip) { VoIPWindowView windowView = new VoIPWindowView(activity, !transitionFromPip) {
@Override @Override
@ -333,7 +335,7 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
h -= instance.lastInsets.getSystemWindowInsetBottom(); h -= instance.lastInsets.getSystemWindowInsetBottom();
} }
if (instance.canSwitchToPip) { if (instance.canSwitchToPip) {
VoIPPiPView.show(instance.activity, instance.windowView.getMeasuredWidth(), h, VoIPPiPView.ANIMATION_ENTER_TYPE_SCALE); VoIPPiPView.show(instance.activity, instance.currentAccount, instance.windowView.getMeasuredWidth(), h, VoIPPiPView.ANIMATION_ENTER_TYPE_SCALE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH && instance.lastInsets != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH && instance.lastInsets != null) {
VoIPPiPView.topInset = instance.lastInsets.getSystemWindowInsetTop(); VoIPPiPView.topInset = instance.lastInsets.getSystemWindowInsetTop();
VoIPPiPView.bottomInset = instance.lastInsets.getSystemWindowInsetBottom(); VoIPPiPView.bottomInset = instance.lastInsets.getSystemWindowInsetBottom();
@ -379,13 +381,13 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
} }
public VoIPFragment() { public VoIPFragment() {
currentUser = MessagesController.getInstance(UserConfig.selectedAccount).getUser(UserConfig.getInstance(UserConfig.selectedAccount).getClientUserId()); currentUser = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
callingUser = VoIPService.getSharedInstance().getUser(); callingUser = VoIPService.getSharedInstance().getUser();
VoIPService.getSharedInstance().registerStateListener(this); VoIPService.getSharedInstance().registerStateListener(this);
isOutgoing = VoIPService.getSharedInstance().isOutgoing(); isOutgoing = VoIPService.getSharedInstance().isOutgoing();
previousState = -1; previousState = -1;
currentState = VoIPService.getSharedInstance().getCallState(); currentState = VoIPService.getSharedInstance().getCallState();
NotificationCenter.getInstance(UserConfig.selectedAccount).addObserver(this, NotificationCenter.voipServiceCreated); NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.voipServiceCreated);
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiDidLoad); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiDidLoad);
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.closeInCallActivity); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.closeInCallActivity);
} }
@ -395,7 +397,7 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
if (service != null) { if (service != null) {
service.unregisterStateListener(this); service.unregisterStateListener(this);
} }
NotificationCenter.getInstance(UserConfig.selectedAccount).removeObserver(this, NotificationCenter.voipServiceCreated); NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.voipServiceCreated);
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiDidLoad); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiDidLoad);
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.closeInCallActivity); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.closeInCallActivity);
} }
@ -732,7 +734,7 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
intent.putExtra("start_incall_activity", false); intent.putExtra("start_incall_activity", false);
intent.putExtra("video_call", isVideoCall); intent.putExtra("video_call", isVideoCall);
intent.putExtra("can_video_call", isVideoCall); intent.putExtra("can_video_call", isVideoCall);
intent.putExtra("account", UserConfig.selectedAccount); intent.putExtra("account", currentAccount);
try { try {
activity.startService(intent); activity.startService(intent);
} catch (Throwable e) { } catch (Throwable e) {
@ -863,7 +865,7 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH && instance.lastInsets != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH && instance.lastInsets != null) {
h -= instance.lastInsets.getSystemWindowInsetBottom(); h -= instance.lastInsets.getSystemWindowInsetBottom();
} }
VoIPPiPView.show(instance.activity, instance.windowView.getMeasuredWidth(), h, VoIPPiPView.ANIMATION_ENTER_TYPE_TRANSITION); VoIPPiPView.show(instance.activity, instance.currentAccount, instance.windowView.getMeasuredWidth(), h, VoIPPiPView.ANIMATION_ENTER_TYPE_TRANSITION);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH && instance.lastInsets != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH && instance.lastInsets != null) {
VoIPPiPView.topInset = instance.lastInsets.getSystemWindowInsetTop(); VoIPPiPView.topInset = instance.lastInsets.getSystemWindowInsetTop();
VoIPPiPView.bottomInset = instance.lastInsets.getSystemWindowInsetBottom(); VoIPPiPView.bottomInset = instance.lastInsets.getSystemWindowInsetBottom();
@ -883,13 +885,13 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
VoIPPiPView.switchingToPip = true; VoIPPiPView.switchingToPip = true;
switchingToPip = true; switchingToPip = true;
Animator animator = createPiPTransition(false); Animator animator = createPiPTransition(false);
animationIndex = NotificationCenter.getInstance(UserConfig.selectedAccount).setAnimationInProgress(animationIndex, null); animationIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(animationIndex, null);
animator.addListener(new AnimatorListenerAdapter() { animator.addListener(new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
VoIPPiPView.getInstance().windowView.setAlpha(1f); VoIPPiPView.getInstance().windowView.setAlpha(1f);
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
NotificationCenter.getInstance(UserConfig.selectedAccount).onAnimationFinish(animationIndex); NotificationCenter.getInstance(currentAccount).onAnimationFinish(animationIndex);
VoIPPiPView.getInstance().onTransitionEnd(); VoIPPiPView.getInstance().onTransitionEnd();
currentUserCameraFloatingLayout.setCornerRadius(-1f); currentUserCameraFloatingLayout.setCornerRadius(-1f);
callingUserTextureView.renderer.release(); callingUserTextureView.renderer.release();
@ -920,7 +922,7 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
switchingToPip = true; switchingToPip = true;
VoIPPiPView.switchingToPip = true; VoIPPiPView.switchingToPip = true;
VoIPPiPView.prepareForTransition(); VoIPPiPView.prepareForTransition();
animationIndex = NotificationCenter.getInstance(UserConfig.selectedAccount).setAnimationInProgress(animationIndex, null); animationIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(animationIndex, null);
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
windowView.setAlpha(1f); windowView.setAlpha(1f);
Animator animator = createPiPTransition(true); Animator animator = createPiPTransition(true);
@ -953,7 +955,7 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
animator.addListener(new AnimatorListenerAdapter() { animator.addListener(new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
NotificationCenter.getInstance(UserConfig.selectedAccount).onAnimationFinish(animationIndex); NotificationCenter.getInstance(currentAccount).onAnimationFinish(animationIndex);
currentUserCameraFloatingLayout.setCornerRadius(-1f); currentUserCameraFloatingLayout.setCornerRadius(-1f);
switchingToPip = false; switchingToPip = false;
currentUserCameraFloatingLayout.switchingToPip = false; currentUserCameraFloatingLayout.switchingToPip = false;
@ -1252,7 +1254,7 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
intent.putExtra("start_incall_activity", false); intent.putExtra("start_incall_activity", false);
intent.putExtra("video_call", false); intent.putExtra("video_call", false);
intent.putExtra("can_video_call", false); intent.putExtra("can_video_call", false);
intent.putExtra("account", UserConfig.selectedAccount); intent.putExtra("account", currentAccount);
try { try {
activity.startService(intent); activity.startService(intent);
} catch (Throwable e) { } catch (Throwable e) {
@ -2052,7 +2054,7 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH && instance.lastInsets != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH && instance.lastInsets != null) {
h -= instance.lastInsets.getSystemWindowInsetBottom(); h -= instance.lastInsets.getSystemWindowInsetBottom();
} }
VoIPPiPView.show(instance.activity, instance.windowView.getMeasuredWidth(), h, VoIPPiPView.ANIMATION_ENTER_TYPE_SCALE); VoIPPiPView.show(instance.activity, instance.currentAccount, instance.windowView.getMeasuredWidth(), h, VoIPPiPView.ANIMATION_ENTER_TYPE_SCALE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH && instance.lastInsets != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH && instance.lastInsets != null) {
VoIPPiPView.topInset = instance.lastInsets.getSystemWindowInsetTop(); VoIPPiPView.topInset = instance.lastInsets.getSystemWindowInsetTop();
VoIPPiPView.bottomInset = instance.lastInsets.getSystemWindowInsetBottom(); VoIPPiPView.bottomInset = instance.lastInsets.getSystemWindowInsetBottom();