Update to 7.2.1 (2139)

This commit is contained in:
DrKLO 2020-11-01 00:13:37 +03:00
parent 00e58e8782
commit 5a47056c7b
22 changed files with 132 additions and 105 deletions

View file

@ -285,7 +285,7 @@ android {
} }
} }
defaultConfig.versionCode = 2137 defaultConfig.versionCode = 2139
applicationVariants.all { variant -> applicationVariants.all { variant ->
variant.outputs.all { output -> variant.outputs.all { output ->

View file

@ -18,7 +18,7 @@ public class BuildVars {
public static boolean LOGS_ENABLED = false; public static boolean LOGS_ENABLED = false;
public static boolean USE_CLOUD_STRINGS = true; public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true; public static boolean CHECK_UPDATES = true;
public static int BUILD_VERSION = 2137; public static int BUILD_VERSION = 2139;
public static String BUILD_VERSION_STRING = "7.2.0"; public static String BUILD_VERSION_STRING = "7.2.0";
public static int APP_ID = 4; public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

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

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

View file

@ -233,9 +233,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());
@ -2810,6 +2811,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

@ -4081,7 +4081,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;
@ -4094,10 +4094,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) {
@ -4105,6 +4101,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

@ -4253,7 +4253,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) {
@ -4263,11 +4263,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);
} }
@ -4275,15 +4280,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) {
@ -4293,7 +4291,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);
@ -4373,7 +4371,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);
@ -4420,7 +4418,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);
@ -4468,7 +4466,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

@ -1224,7 +1224,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: {
@ -10863,11 +10863,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()) {
@ -10880,14 +10879,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

@ -276,7 +276,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

@ -878,7 +878,9 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
message.messageObjects.remove(index); message.messageObjects.remove(index);
message.messages.remove(index); message.messages.remove(index);
message.originalPaths.remove(index); message.originalPaths.remove(index);
if (!message.parentObjects.isEmpty()) {
message.parentObjects.remove(index); 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);
@ -5465,7 +5467,7 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
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();
@ -5525,7 +5527,7 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
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

@ -271,6 +271,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

@ -3414,7 +3414,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;
@ -3448,7 +3448,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;
} }
@ -3497,7 +3497,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) {
@ -3536,7 +3536,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;
@ -3554,7 +3554,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) {
@ -4240,7 +4240,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;
} }
@ -12691,7 +12691,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

@ -1715,7 +1715,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;
} }
@ -1724,7 +1724,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

@ -490,6 +490,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;
@ -634,6 +635,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,
@ -1486,6 +1488,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);
@ -4020,13 +4024,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);
@ -4048,9 +4051,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");
@ -4066,9 +4069,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");
@ -11158,11 +11161,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);
} }
@ -11371,9 +11375,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();
}
}); });
} }
@ -14945,6 +14947,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

@ -1890,9 +1890,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

@ -3367,13 +3367,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);
@ -3673,6 +3673,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);
@ -6622,12 +6623,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();
} }
} }
@ -6665,11 +6666,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 {
@ -6709,14 +6710,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 {
@ -6998,11 +6999,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();
} }
} }
@ -7383,12 +7384,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();
@ -7431,14 +7432,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

@ -239,7 +239,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

@ -2236,7 +2236,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();