1
0
mirror of https://github.com/NekoX-Dev/NekoX.git synced 2024-12-16 07:39:26 +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-extensions'
def verName = "7.2.1-preview04"
def verCode = 96
def verName = "7.2.1-preview05"
def verCode = 98
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");
if (messageObject != null && messageObject.isVideo()) {
getMessagesController().sendTyping(dialogId, topMessageId, 5, 0);
} else if (messageObject != null && messageObject.getDocument() != null) {
getMessagesController().sendTyping(dialogId, topMessageId, 3, 0);
} else {
getMessagesController().sendTyping(dialogId, topMessageId, 4, 0);
}

View File

@ -405,9 +405,11 @@ public class ImageLoader {
@Override
protected void onPostExecute(final String result) {
if (result != null) {
cacheImage.httpTask = new HttpImageTask(cacheImage, 0, result);
httpTasks.add(cacheImage.httpTask);
runHttpTasks(false);
imageLoadQueue.postRunnable(() -> {
cacheImage.httpTask = new HttpImageTask(cacheImage, 0, result);
httpTasks.add(cacheImage.httpTask);
runHttpTasks(false);
});
} else if (canRetry) {
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",
"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());
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[]{"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[]{"lt"}, new PluralRules_Lithuanian());
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 int quantityForNumber(int count) {
int rem100 = count % 100;

View File

@ -4112,7 +4112,7 @@ public class MessageObject {
lastLineWidth = linesMaxWidth;
}
linesMaxWidthWithLeft = lastLineWidthWithLeft = (int) Math.ceil(lastLine + lastLeft);
linesMaxWidthWithLeft = lastLineWidthWithLeft = (int) Math.ceil(linesMaxWidth + Math.max(0, lastLeft));
if (currentBlockLinesCount > 1) {
boolean hasNonRTL = false;
@ -4125,10 +4125,6 @@ public class MessageObject {
lineWidth = 0;
}
if (lineWidth > maxWidth + 20) {
lineWidth = maxWidth;
}
try {
lineLeft = block.textLayout.getLineLeft(n);
} catch (Exception e) {
@ -4136,6 +4132,11 @@ public class MessageObject {
lineLeft = 0;
}
if (lineWidth > maxWidth + 20) {
lineWidth = maxWidth;
lineLeft = 0;
}
if (lineLeft > 0) {
textXOffset = Math.min(textXOffset, lineLeft);
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) {
deleteDialog(did, true, onlyHistory, 0, revoke, null, 0);
deleteDialog(did, 1, onlyHistory, 0, revoke, null, 0);
}
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) {
getMessagesStorage().deleteDialog(did, onlyHistory);
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) {
getMediaDataController().uninstallShortcut(did);
}
@ -4427,15 +4432,8 @@ public class MessagesController extends BaseController implements NotificationCe
int high_id = (int) (did >> 32);
int max_id_delete = max_id;
if (first) {
if (first != 0) {
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);
TLRPC.Dialog dialog = dialogs_dict.get(did);
if (onlyHistory == 0 || onlyHistory == 3) {
@ -4445,7 +4443,7 @@ public class MessagesController extends BaseController implements NotificationCe
getMediaDataController().cleanDraft(did, 0, false);
}
if (dialog != null) {
if (emptyMax) {
if (first == 2) {
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_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);
if (max != null) {
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.writeInt32(13);
data.writeInt64(did);
data.writeBool(first);
data.writeBool(first != 0);
data.writeInt32(onlyHistory);
data.writeInt32(max_id_delete);
data.writeBool(revoke);
@ -4620,7 +4618,7 @@ public class MessagesController extends BaseController implements NotificationCe
if (error == null) {
TLRPC.TL_messages_affectedHistory res = (TLRPC.TL_messages_affectedHistory) response;
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);
getMessagesStorage().onDeleteQueryComplete(did);

View File

@ -1233,7 +1233,7 @@ public class MessagesStorage extends BaseController {
final int maxIdDelete = data.readInt32(false);
final boolean revoke = data.readBool(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;
}
case 15: {
@ -10889,11 +10889,10 @@ public class MessagesStorage extends BaseController {
});
}
public int getDialogMaxMessageId(final long dialog_id) {
final CountDownLatch countDownLatch = new CountDownLatch(1);
final Integer[] max = new Integer[]{0};
public void getDialogMaxMessageId(final long dialog_id, IntCallback callback) {
storageQueue.postRunnable(() -> {
SQLiteCursor cursor = null;
int[] max = new int[1];
try {
cursor = database.queryFinalized("SELECT MAX(mid) FROM messages WHERE uid = " + dialog_id);
if (cursor.next()) {
@ -10906,14 +10905,8 @@ public class MessagesStorage extends BaseController {
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) {

View File

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

View File

@ -871,7 +871,9 @@ public boolean retriedToSend;
message.messageObjects.remove(index);
message.messages.remove(index);
message.originalPaths.remove(index);
message.parentObjects.remove(index);
if (!message.parentObjects.isEmpty()) {
message.parentObjects.remove(index);
}
if (message.sendRequest != null) {
TLRPC.TL_messages_sendMultiMedia request = (TLRPC.TL_messages_sendMultiMedia) message.sendRequest;
request.multi_media.remove(index);
@ -5444,7 +5446,7 @@ public boolean retriedToSend;
docType[0] = 0;
}
}
if (groupId != null) {
if (!isEncrypted && groupId != null) {
if (docType != null && prevType != null && prevType != docType[0]) {
finishGroup(accountInstance, groupId[0], scheduleDate);
groupId[0] = Utilities.random.nextLong();
@ -5504,7 +5506,7 @@ public boolean retriedToSend;
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();
mediaCount = 0;
}

View File

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

View File

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

View File

@ -1712,7 +1712,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
@Override
public void onTransitionAnimationStart(boolean isOpen, boolean backward) {
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*/});
openAnimationEnded = false;
}
@ -1721,7 +1721,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
@Override
public void onTransitionAnimationEnd(boolean isOpen, boolean backward) {
if (isOpen) {
NotificationCenter.getInstance(currentAccount).onAnimationFinish(allowAnimationIndex);
getNotificationCenter().onAnimationFinish(allowAnimationIndex);
openAnimationEnded = true;
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -102,6 +102,8 @@ public class VoIPPiPView implements VoIPBaseService.StateListener, NotificationC
long startTime;
int animationIndex = -1;
private int currentAccount;
Runnable collapseRunnable = new Runnable() {
@Override
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) {
return;
}
@ -142,6 +144,7 @@ public class VoIPPiPView implements VoIPBaseService.StateListener, NotificationC
instance = new VoIPPiPView(activity, parentWidth, parentHeight, false);
WindowManager wm = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE);
instance.currentAccount = account;
instance.windowManager = wm;
instance.windowLayoutParams = windowLayoutParams;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("voippipconfig", Context.MODE_PRIVATE);
@ -334,7 +337,7 @@ public class VoIPPiPView implements VoIPBaseService.StateListener, NotificationC
enlargeIcon.setOnClickListener((v) -> {
if (context instanceof LaunchActivity && !ApplicationLoader.mainInterfacePaused) {
VoIPFragment.show((Activity) context);
VoIPFragment.show((Activity) context, currentAccount);
} else if (context instanceof LaunchActivity) {
Intent intent = new Intent(context, LaunchActivity.class);
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) {
Context context = getContext();
if (context instanceof LaunchActivity && !ApplicationLoader.mainInterfacePaused) {
VoIPFragment.show((Activity) context);
VoIPFragment.show((Activity) context, currentAccount);
} else if (context instanceof LaunchActivity) {
Intent intent = new Intent(context, LaunchActivity.class);
intent.setAction("voip");

View File

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

View File

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

View File

@ -1448,7 +1448,7 @@ public class ThemePreviewActivity extends BaseFragment implements DownloadContro
public int getDefaultColor(int num) {
if (colorType == 3 && applyingTheme.firstAccentIsDefault && num == 0) {
Theme.ThemeAccent accent = applyingTheme.themeAccentsMap.get(Theme.DEFALT_THEME_ACCENT_ID);
return accent.myMessagesAccentColor;
return accent != null ? accent.myMessagesAccentColor : 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_FLOATING = 2;
private int currentAccount;
Activity activity;
TLRPC.User currentUser;
@ -205,12 +207,11 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
private boolean screenWasWakeup;
private boolean isVideoCall;
public static void show(Activity activity) {
show(activity, false);
public static void show(Activity activity, int account) {
show(activity, false, account);
}
public static void show(Activity activity, boolean overlay) {
public static void show(Activity activity, boolean overlay, int account) {
if (instance != null && instance.windowView.getParent() == null) {
if (instance != null) {
instance.callingUserTextureView.renderer.release();
@ -229,6 +230,7 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
}
VoIPFragment fragment = new VoIPFragment();
fragment.activity = activity;
fragment.currentAccount = account;
instance = fragment;
VoIPWindowView windowView = new VoIPWindowView(activity, !transitionFromPip) {
@Override
@ -333,7 +335,7 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
h -= instance.lastInsets.getSystemWindowInsetBottom();
}
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) {
VoIPPiPView.topInset = instance.lastInsets.getSystemWindowInsetTop();
VoIPPiPView.bottomInset = instance.lastInsets.getSystemWindowInsetBottom();
@ -379,13 +381,13 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
}
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();
VoIPService.getSharedInstance().registerStateListener(this);
isOutgoing = VoIPService.getSharedInstance().isOutgoing();
previousState = -1;
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.closeInCallActivity);
}
@ -395,7 +397,7 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
if (service != null) {
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.closeInCallActivity);
}
@ -732,7 +734,7 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
intent.putExtra("start_incall_activity", false);
intent.putExtra("video_call", isVideoCall);
intent.putExtra("can_video_call", isVideoCall);
intent.putExtra("account", UserConfig.selectedAccount);
intent.putExtra("account", currentAccount);
try {
activity.startService(intent);
} 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) {
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) {
VoIPPiPView.topInset = instance.lastInsets.getSystemWindowInsetTop();
VoIPPiPView.bottomInset = instance.lastInsets.getSystemWindowInsetBottom();
@ -883,13 +885,13 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
VoIPPiPView.switchingToPip = true;
switchingToPip = true;
Animator animator = createPiPTransition(false);
animationIndex = NotificationCenter.getInstance(UserConfig.selectedAccount).setAnimationInProgress(animationIndex, null);
animationIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(animationIndex, null);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
VoIPPiPView.getInstance().windowView.setAlpha(1f);
AndroidUtilities.runOnUIThread(() -> {
NotificationCenter.getInstance(UserConfig.selectedAccount).onAnimationFinish(animationIndex);
NotificationCenter.getInstance(currentAccount).onAnimationFinish(animationIndex);
VoIPPiPView.getInstance().onTransitionEnd();
currentUserCameraFloatingLayout.setCornerRadius(-1f);
callingUserTextureView.renderer.release();
@ -920,7 +922,7 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
switchingToPip = true;
VoIPPiPView.switchingToPip = true;
VoIPPiPView.prepareForTransition();
animationIndex = NotificationCenter.getInstance(UserConfig.selectedAccount).setAnimationInProgress(animationIndex, null);
animationIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(animationIndex, null);
AndroidUtilities.runOnUIThread(() -> {
windowView.setAlpha(1f);
Animator animator = createPiPTransition(true);
@ -953,7 +955,7 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
NotificationCenter.getInstance(UserConfig.selectedAccount).onAnimationFinish(animationIndex);
NotificationCenter.getInstance(currentAccount).onAnimationFinish(animationIndex);
currentUserCameraFloatingLayout.setCornerRadius(-1f);
switchingToPip = false;
currentUserCameraFloatingLayout.switchingToPip = false;
@ -1252,7 +1254,7 @@ public class VoIPFragment implements VoIPBaseService.StateListener, Notification
intent.putExtra("start_incall_activity", false);
intent.putExtra("video_call", false);
intent.putExtra("can_video_call", false);
intent.putExtra("account", UserConfig.selectedAccount);
intent.putExtra("account", currentAccount);
try {
activity.startService(intent);
} 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) {
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) {
VoIPPiPView.topInset = instance.lastInsets.getSystemWindowInsetTop();
VoIPPiPView.bottomInset = instance.lastInsets.getSystemWindowInsetBottom();