1
0
mirror of https://github.com/MGislv/NekoX.git synced 2024-07-02 10:33:36 +00:00

Update to 7.9.3 (2390)

This commit is contained in:
DrKLO 2021-08-07 02:55:04 +03:00
parent fc12550efb
commit ab221dafad
21 changed files with 548 additions and 182 deletions

View File

@ -17,7 +17,7 @@ configurations.all {
dependencies {
implementation 'androidx.core:core:1.6.0'
implementation 'androidx.palette:palette:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.3.2'
implementation 'androidx.exifinterface:exifinterface:1.3.3'
implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation "androidx.sharetarget:sharetarget:1.1.0"
@ -29,7 +29,7 @@ dependencies {
implementation 'com.google.firebase:firebase-datatransport:18.0.1'
implementation 'com.google.firebase:firebase-appindexing:20.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.1'
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation 'com.google.android.gms:play-services-auth:19.2.0'
implementation 'com.google.android.gms:play-services-vision:16.2.0'
implementation 'com.google.android.gms:play-services-wearable:17.1.0'
implementation 'com.google.android.gms:play-services-location:18.0.0'
@ -299,7 +299,7 @@ android {
}
}
defaultConfig.versionCode = 2389
defaultConfig.versionCode = 2390
applicationVariants.all { variant ->
variant.outputs.all { output ->
@ -318,7 +318,7 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 29
versionName "7.9.2"
versionName "7.9.3"
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

View File

@ -19,8 +19,8 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true;
public static boolean NO_SCOPED_STORAGE = true/* || Build.VERSION.SDK_INT <= 28*/;
public static int BUILD_VERSION = 2389;
public static String BUILD_VERSION_STRING = "7.9.2";
public static int BUILD_VERSION = 2390;
public static String BUILD_VERSION_STRING = "7.9.3";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
public static String APPCENTER_HASH = "a5b5c4f5-51da-dedc-9918-d9766a22ca7c";

View File

@ -4048,7 +4048,7 @@ public class MediaDataController extends BaseController {
}
}
}
AndroidUtilities.runOnUIThread(() -> getNotificationCenter().postNotificationName(NotificationCenter.replyMessagesDidLoad, dialogId, loadedMessages));
AndroidUtilities.runOnUIThread(() -> getNotificationCenter().postNotificationName(NotificationCenter.replyMessagesDidLoad, dialogId, loadedMessages, null));
if (callback != null) {
callback.run();
}
@ -4270,7 +4270,7 @@ public class MediaDataController extends BaseController {
}
}
if (changed) {
getNotificationCenter().postNotificationName(NotificationCenter.replyMessagesDidLoad, dialog_id, messageObjects);
getNotificationCenter().postNotificationName(NotificationCenter.replyMessagesDidLoad, dialog_id, messageObjects, replyMessageOwners);
}
});
}

View File

@ -3506,8 +3506,12 @@ public class MessageObject {
}
public String getFileName() {
return getFileName(messageOwner);
}
public static String getFileName(TLRPC.Message messageOwner) {
if (messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
return FileLoader.getAttachFileName(getDocument());
return FileLoader.getAttachFileName(getDocument(messageOwner));
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
ArrayList<TLRPC.PhotoSize> sizes = messageOwner.media.photo.sizes;
if (sizes.size() > 0) {

View File

@ -5875,13 +5875,20 @@ public class MessagesController extends BaseController implements NotificationCe
newPrintingStrings.put(threadId, LocaleController.getString("RecordingAudio", R.string.RecordingAudio));
}
newPrintingStringsTypes.put(threadId, 1);
} else if (pu.action instanceof TLRPC.TL_sendMessageRecordRoundAction || pu.action instanceof TLRPC.TL_sendMessageUploadRoundAction) {
} else if (pu.action instanceof TLRPC.TL_sendMessageRecordRoundAction) {
if (lower_id < 0) {
newPrintingStrings.put(threadId, LocaleController.formatString("IsRecordingRound", R.string.IsRecordingRound, getUserNameForTyping(user)));
} else {
newPrintingStrings.put(threadId, LocaleController.getString("RecordingRound", R.string.RecordingRound));
}
newPrintingStringsTypes.put(threadId, 4);
} else if (pu.action instanceof TLRPC.TL_sendMessageUploadRoundAction) {
if (lower_id < 0) {
newPrintingStrings.put(threadId, LocaleController.formatString("IsSendingVideo", R.string.IsSendingVideo, getUserNameForTyping(user)));
} else {
newPrintingStrings.put(threadId, LocaleController.getString("SendingVideoStatus", R.string.SendingVideoStatus));
}
newPrintingStringsTypes.put(threadId, 4);
} else if (pu.action instanceof TLRPC.TL_sendMessageUploadAudioAction) {
if (lower_id < 0) {
newPrintingStrings.put(threadId, LocaleController.formatString("IsSendingAudio", R.string.IsSendingAudio, getUserNameForTyping(user)));
@ -5889,13 +5896,20 @@ public class MessagesController extends BaseController implements NotificationCe
newPrintingStrings.put(threadId, LocaleController.getString("SendingAudio", R.string.SendingAudio));
}
newPrintingStringsTypes.put(threadId, 2);
} else if (pu.action instanceof TLRPC.TL_sendMessageUploadVideoAction || pu.action instanceof TLRPC.TL_sendMessageRecordVideoAction) {
} else if (pu.action instanceof TLRPC.TL_sendMessageUploadVideoAction) {
if (lower_id < 0) {
newPrintingStrings.put(threadId, LocaleController.formatString("IsSendingVideo", R.string.IsSendingVideo, getUserNameForTyping(user)));
} else {
newPrintingStrings.put(threadId, LocaleController.getString("SendingVideoStatus", R.string.SendingVideoStatus));
}
newPrintingStringsTypes.put(threadId, 2);
} else if (pu.action instanceof TLRPC.TL_sendMessageRecordVideoAction) {
if (lower_id < 0) {
newPrintingStrings.put(threadId, LocaleController.formatString("IsRecordingVideo", R.string.IsRecordingVideo, getUserNameForTyping(user)));
} else {
newPrintingStrings.put(threadId, LocaleController.getString("RecordingVideoStatus", R.string.RecordingVideoStatus));
}
newPrintingStringsTypes.put(threadId, 2);
} else if (pu.action instanceof TLRPC.TL_sendMessageUploadDocumentAction) {
if (lower_id < 0) {
newPrintingStrings.put(threadId, LocaleController.formatString("IsSendingFile", R.string.IsSendingFile, getUserNameForTyping(user)));
@ -5917,6 +5931,20 @@ public class MessagesController extends BaseController implements NotificationCe
newPrintingStrings.put(threadId, LocaleController.getString("SendingGame", R.string.SendingGame));
}
newPrintingStringsTypes.put(threadId, 3);
} else if (pu.action instanceof TLRPC.TL_sendMessageGeoLocationAction) {
if (lower_id < 0) {
newPrintingStrings.put(threadId, LocaleController.formatString("IsSelectingLocation", R.string.IsSelectingLocation, getUserNameForTyping(user)));
} else {
newPrintingStrings.put(threadId, LocaleController.getString("SelectingLocation", R.string.SelectingLocation));
}
newPrintingStringsTypes.put(threadId, 0);
} else if (pu.action instanceof TLRPC.TL_sendMessageChooseContactAction) {
if (lower_id < 0) {
newPrintingStrings.put(threadId, LocaleController.formatString("IsSelectingContact", R.string.IsSelectingContact, getUserNameForTyping(user)));
} else {
newPrintingStrings.put(threadId, LocaleController.getString("SelectingContact", R.string.SelectingContact));
}
newPrintingStringsTypes.put(threadId, 0);
} else {
if (lower_id < 0) {
newPrintingStrings.put(threadId, LocaleController.formatString("IsTypingGroup", R.string.IsTypingGroup, getUserNameForTyping(user)));

View File

@ -3725,6 +3725,9 @@ public class MessagesStorage extends BaseController {
arr.add(m);
}
cursor.dispose();
if (media == null) {
media = false;
}
getMessagesController().processLoadedDeleteTask(date, arr, media, channelId1);
} catch (Exception e) {
FileLog.e(e);
@ -10369,7 +10372,9 @@ public class MessagesStorage extends BaseController {
data.reuse();
int send_state = cursor.intValue(5);
if (send_state != 3) {
message.attachPath = oldMessage.attachPath;
if (MessageObject.getFileName(oldMessage).equals(MessageObject.getFileName(message))) {
message.attachPath = oldMessage.attachPath;
}
message.ttl = cursor.intValue(2);
}
boolean sameMedia = false;

View File

@ -1670,6 +1670,9 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
}
}
}
if (chat != null) {
rank = getMessagesController().getAdminRank(chat.id, myId);
}
canSendStickers = ChatObject.canSendStickers(chat);
canSendMedia = ChatObject.canSendMedia(chat);
canSendPreview = ChatObject.canSendEmbed(chat);

View File

@ -480,6 +480,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
private int miniButtonPressed;
private int otherX;
private int otherY;
private int lastWidth;
private int lastHeight;
private int hasMiniProgress;
private int miniButtonState;
@ -566,6 +567,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
private float hintButtonProgress;
private String lastPostAuthor;
private TLRPC.Message lastReplyMessage;
private boolean hasPsaHint;
private int psaHelpX;
@ -3030,14 +3032,18 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (messageObject.checkLayout() || currentPosition != null && lastHeight != AndroidUtilities.displaySize.y) {
currentMessageObject = null;
}
boolean widthChanged = lastWidth != AndroidUtilities.displaySize.x;
lastHeight = AndroidUtilities.displaySize.y;
lastWidth = AndroidUtilities.displaySize.x;
isRoundVideo = messageObject != null && messageObject.isRoundVideo();
TLRPC.Message newReply = messageObject.hasValidReplyMessageObject() ? messageObject.replyMessageObject.messageOwner : null;
boolean messageIdChanged = currentMessageObject == null || currentMessageObject.getId() != messageObject.getId();
boolean messageChanged = currentMessageObject != messageObject || messageObject.forceUpdate || (isRoundVideo && isPlayingRound != (MediaController.getInstance().isPlayingMessage(currentMessageObject) && delegate != null && !delegate.keyboardIsOpened()));
boolean dataChanged = currentMessageObject != null && currentMessageObject.getId() == messageObject.getId() && lastSendState == MessageObject.MESSAGE_SEND_STATE_EDITING && messageObject.isSent()
|| currentMessageObject == messageObject && (isUserDataChanged() || photoNotSet)
|| lastPostAuthor != messageObject.messageOwner.post_author
|| wasPinned != isPinned;
boolean dataChanged = currentMessageObject != null && currentMessageObject.getId() == messageObject.getId() && lastSendState == MessageObject.MESSAGE_SEND_STATE_EDITING && messageObject.isSent() ||
currentMessageObject == messageObject && (isUserDataChanged() || photoNotSet) ||
lastPostAuthor != messageObject.messageOwner.post_author ||
wasPinned != isPinned ||
newReply != lastReplyMessage;
boolean groupChanged = groupedMessages != currentMessagesGroup;
boolean pollChanged = false;
if (drawCommentButton || drawSideButton == 3 && !((hasDiscussion && messageObject.isLinkedToChat(linkedChatId) || isRepliesChat) && (currentPosition == null || currentPosition.siblingHeights == null && (currentPosition.flags & MessageObject.POSITION_FLAG_BOTTOM) != 0 || currentPosition.siblingHeights != null && (currentPosition.flags & MessageObject.POSITION_FLAG_TOP) == 0))) {
@ -3087,7 +3093,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
groupChanged = newPosition != currentPosition;
}
if (messageChanged || dataChanged || groupChanged || pollChanged || isPhotoDataChanged(messageObject) || pinnedBottom != bottomNear || pinnedTop != topNear) {
if (messageChanged || dataChanged || groupChanged || pollChanged || widthChanged && messageObject.isPoll() || isPhotoDataChanged(messageObject) || pinnedBottom != bottomNear || pinnedTop != topNear) {
wasPinned = isPinned;
pinnedBottom = bottomNear;
pinnedTop = topNear;
@ -3144,6 +3150,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
adminLayout = null;
checkOnlyButtonPressed = false;
replyTextLayout = null;
lastReplyMessage = null;
hasEmbed = false;
autoPlayingMedia = false;
replyNameWidth = 0;
@ -9643,12 +9650,12 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
int adminWidth;
String adminString;
String adminLabel;
if (isMegagroup && currentChat != null && currentMessageObject.isForwardedChannelPost()) {
adminString = LocaleController.getString("DiscussChannel", R.string.DiscussChannel);
if (isMegagroup && currentChat != null && messageObject.messageOwner.post_author != null && currentChat.id == -currentMessageObject.getFromChatId()) {
adminString = messageObject.messageOwner.post_author.replace("\n", "");
adminWidth = (int) Math.ceil(Theme.chat_adminPaint.measureText(adminString));
nameWidth -= adminWidth;
} else if (isMegagroup && currentChat != null && messageObject.messageOwner.post_author != null && currentChat.id == -currentMessageObject.getFromChatId()) {
adminString = messageObject.messageOwner.post_author.replace("\n", "");
} else if (isMegagroup && currentChat != null && currentMessageObject.isForwardedChannelPost()) {
adminString = LocaleController.getString("DiscussChannel", R.string.DiscussChannel);
adminWidth = (int) Math.ceil(Theme.chat_adminPaint.measureText(adminString));
nameWidth -= adminWidth;
} else if (currentUser != null && !currentMessageObject.isOutOwner() && !currentMessageObject.isAnyKindOfSticker() && currentMessageObject.type != 5 && delegate != null && (adminLabel = delegate.getAdminRank(currentUser.id)) != null) {
@ -9749,6 +9756,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (currentForwardChannel != null) {
if (currentForwardUser != null) {
currentForwardNameString = String.format("%s (%s)", currentForwardChannel.title, UserObject.getUserName(currentForwardUser));
} else if (!TextUtils.isEmpty(messageObject.messageOwner.fwd_from.post_author)) {
currentForwardNameString = String.format("%s (%s)", currentForwardChannel.title, messageObject.messageOwner.fwd_from.post_author);
} else {
currentForwardNameString = currentForwardChannel.title;
}
@ -9828,6 +9837,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
String name = null;
if ((!isThreadChat || messageObject.getReplyTopMsgId() != 0) && messageObject.hasValidReplyMessageObject()) {
lastReplyMessage = messageObject.replyMessageObject.messageOwner;
int cacheType = 1;
int size = 0;
TLObject photoObject;
@ -10792,18 +10802,18 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
return getBackgroundDrawableTop() + layoutHeight - offsetBottom + additionalBottom;
}
public void drawBackground(Canvas canvas, int left, int top, int right, int bottom, boolean pinnedTop, boolean pinnedBottom) {
public void drawBackground(Canvas canvas, int left, int top, int right, int bottom, boolean pinnedTop, boolean pinnedBottom, boolean selected) {
if (currentMessageObject.isOutOwner()) {
if (!mediaBackground && !pinnedBottom) {
currentBackgroundDrawable = Theme.chat_msgOutDrawable;
currentBackgroundDrawable = selected ? Theme.chat_msgOutSelectedDrawable : Theme.chat_msgOutDrawable;
} else {
currentBackgroundDrawable = Theme.chat_msgOutMediaDrawable;
currentBackgroundDrawable = selected ? Theme.chat_msgOutMediaSelectedDrawable : Theme.chat_msgOutMediaDrawable;
}
} else {
if (!mediaBackground && !pinnedBottom) {
currentBackgroundDrawable = Theme.chat_msgInDrawable;
currentBackgroundDrawable = selected ? Theme.chat_msgInSelectedDrawable : Theme.chat_msgInDrawable;
} else {
currentBackgroundDrawable = Theme.chat_msgInMediaDrawable;
currentBackgroundDrawable = selected ? Theme.chat_msgInMediaSelectedDrawable : Theme.chat_msgInMediaDrawable;
}
}

View File

@ -65,9 +65,9 @@ public class StickerSetNameCell extends FrameLayout {
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setSingleLine(true);
if (supportRtl) {
lp = LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.START, emoji ? 15 : 17, 4, 57, 0);
lp = LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.START, emoji ? 15 : 17, 2, 57, 0);
} else {
lp = LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, emoji ? 15 : 17, 4, 57, 0);
lp = LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, emoji ? 15 : 17, 2, 57, 0);
}
addView(textView, lp);

View File

@ -546,6 +546,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private SparseArray<MessageObject>[] messagesDict = new SparseArray[]{new SparseArray<>(), new SparseArray<>()};
private SparseArray<MessageObject> repliesMessagesDict = new SparseArray<>();
private SparseArray<ArrayList<Integer>> replyMessageOwners = new SparseArray<>();
private HashMap<String, ArrayList<MessageObject>> messagesByDays = new HashMap<>();
protected ArrayList<MessageObject> messages = new ArrayList<>();
private SparseArray<MessageObject> waitingForReplies = new SparseArray<>();
@ -2784,10 +2785,20 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
b = chatListView.getMeasuredHeight() + AndroidUtilities.dp(20);
}
boolean selected = true;
for (int a = 0, N = scrimGroup.messages.size(); a < N; a++) {
MessageObject object = scrimGroup.messages.get(a);
int index = object.getDialogId() == dialog_id ? 0 : 1;
if (selectedMessagesIds[index].indexOfKey(object.getId()) < 0) {
selected = false;
break;
}
}
canvas.save();
canvas.clipRect(0, listTop, getMeasuredWidth(), chatListView.getY() + chatListView.getHeight());
canvas.translate(0, chatListView.getY());
scrimGroup.transitionParams.cell.drawBackground(canvas, (int) l, (int) t, (int) r, (int) b, scrimGroup.transitionParams.pinnedTop, scrimGroup.transitionParams.pinnedBotton);
scrimGroup.transitionParams.cell.drawBackground(canvas, (int) l, (int) t, (int) r, (int) b, scrimGroup.transitionParams.pinnedTop, scrimGroup.transitionParams.pinnedBotton, selected);
canvas.restore();
groupedBackgroundWasDraw = true;
}
@ -3923,7 +3934,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
canvas.save();
canvas.scale(group.transitionParams.cell.getScaleX(), group.transitionParams.cell.getScaleY(), l + (r - l) / 2, t + (b - t) / 2);
}
group.transitionParams.cell.drawBackground(canvas, (int) l, (int) t, (int) r, (int) b, group.transitionParams.pinnedTop, group.transitionParams.pinnedBotton);
boolean selected = true;
for (int a = 0, N = group.messages.size(); a < N; a++) {
MessageObject object = group.messages.get(a);
int index = object.getDialogId() == dialog_id ? 0 : 1;
if (selectedMessagesIds[index].indexOfKey(object.getId()) < 0) {
selected = false;
break;
}
}
group.transitionParams.cell.drawBackground(canvas, (int) l, (int) t, (int) r, (int) b, group.transitionParams.pinnedTop, group.transitionParams.pinnedBotton, selected);
group.transitionParams.cell = null;
group.transitionParams.drawCaptionLayout = group.hasCaption;
if (useScale) {
@ -12743,6 +12763,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
MessageObject obj = messArr.get(a);
if (obj.replyMessageObject != null) {
repliesMessagesDict.put(obj.replyMessageObject.getId(), obj.replyMessageObject);
addReplyMessageOwner(obj, 0);
}
int messageId = obj.getId();
if (threadMessageId != 0) {
@ -13759,6 +13780,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
obj.messageOwner.id = newMsgId;
obj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
obj.forceUpdate = mediaUpdated;
addReplyMessageOwner(obj, msgId);
if (args.length >= 6) {
obj.applyMediaExistanceFlags((Integer) args[5]);
}
@ -14391,10 +14413,19 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
long did = (Long) args[0];
if (did == dialog_id) {
ArrayList<MessageObject> loadedMessages = (ArrayList<MessageObject>) args[1];
LongSparseArray<ArrayList<MessageObject>> replyMessageOwners = (LongSparseArray<ArrayList<MessageObject>>) args[2];
for (int a = 0, N = loadedMessages.size(); a < N; a++) {
MessageObject obj = loadedMessages.get(a);
repliesMessagesDict.put(obj.getId(), obj);
}
if (replyMessageOwners != null) {
for (int a = 0, N = replyMessageOwners.size(); a < N; a++) {
ArrayList<MessageObject> arrayList = replyMessageOwners.valueAt(a);
for (int b = 0, N2 = arrayList.size(); b < N2; b++) {
addReplyMessageOwner(arrayList.get(b), 0);
}
}
}
updateVisibleRows();
} else if (waitingForReplies.size() != 0 && ChatObject.isChannel(currentChat) && !currentChat.megagroup && chatInfo != null && did == -chatInfo.linked_chat_id) {
checkWaitingForReplies();
@ -15277,6 +15308,47 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
private void addReplyMessageOwner(MessageObject obj, Integer oldId) {
if (obj.replyMessageObject == null) {
return;
}
int id = obj.replyMessageObject.getId();
ArrayList<Integer> ids = replyMessageOwners.get(id);
if (ids == null) {
ids = new ArrayList<>();
replyMessageOwners.put(id, ids);
}
id = obj.getId();
if (!ids.contains(id)) {
ids.add(id);
}
if (oldId != 0) {
ids.remove(oldId);
}
}
private void updateReplyMessageOwners(int id, MessageObject update) {
ArrayList<Integer> ids = replyMessageOwners.get(id);
if (ids == null) {
return;
}
MessageObject emptyMessage = update == null ? new MessageObject(currentAccount, new TLRPC.TL_messageEmpty(), false, false) : null;
for (int a = 0, N = ids.size(); a < N; a++) {
MessageObject object = messagesDict[0].get(ids.get(a));
if (object != null) {
if (update == null) {
object.replyMessageObject = emptyMessage;
} else {
object.replyMessageObject = update;
}
chatAdapter.updateRowWithMessageObject(object, true);
}
}
if (update == null) {
replyMessageOwners.remove(id);
}
}
private void processNewMessages(ArrayList<MessageObject> arr) {
int currentUserId = getUserConfig().getClientUserId();
boolean updateChat = false;
@ -15381,6 +15453,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
messageObject.generatePaymentSentMessageText(null);
}
}
if (messageObject.replyMessageObject != null) {
repliesMessagesDict.put(messageObject.replyMessageObject.getId(), messageObject.replyMessageObject);
addReplyMessageOwner(messageObject, 0);
}
}
if (chatMode == MODE_SCHEDULED && !arr.isEmpty()) {
@ -15918,6 +15995,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
repliesMessagesDict.remove(mid);
updateReplyMessageOwners(mid, null);
}
if (obj != null) {
if (obj.messageOwner.reply_to != null && !(obj.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage)) {
@ -16228,6 +16306,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
}
updateReplyMessageOwners(old.getId(), messageObject);
}
if (newGroups != null) {
for (int b = 0; b < newGroups.size(); b++) {
@ -18086,14 +18165,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (!ignoreAttachOnPause && chatActivityEnterView != null && bottomOverlayChat != null && bottomOverlayChat.getVisibility() != View.VISIBLE) {
chatActivityEnterView.onPause();
replyMessage = replyingMessageObject;
if (!chatActivityEnterView.isEditingMessage()) {
draftMessage = AndroidUtilities.getTrimmedString(chatActivityEnterView.getFieldText());
}
draftMessage = AndroidUtilities.getTrimmedString(chatActivityEnterView.getDraftMessage());
searchWebpage = chatActivityEnterView.isMessageWebPageSearchEnabled();
chatActivityEnterView.setFieldFocused(false);
}
if (chatAttachAlert != null) {
if (!ignoreAttachOnPause){
if (!ignoreAttachOnPause) {
chatAttachAlert.onPause();
} else {
ignoreAttachOnPause = false;

View File

@ -93,8 +93,6 @@ import androidx.customview.widget.ExploreByTouchHelper;
import androidx.recyclerview.widget.ChatListItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.google.android.exoplayer2.util.Log;
import org.telegram.messenger.AccountInstance;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
@ -133,9 +131,7 @@ import org.telegram.ui.PhotoViewer;
import org.telegram.ui.StickersActivity;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
@ -382,6 +378,8 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
public ValueAnimator currentTopViewAnimation;
private ReplaceableIconDrawable botButtonDrawable;
private CharSequence draftMessage;
private boolean isPaste;
private boolean destroyed;
@ -5723,6 +5721,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
if (audioToSend != null || videoToSendMessageObject != null || editingMessageObject == messageObject) {
return;
}
boolean hadEditingMessage = editingMessageObject != null;
editingMessageObject = messageObject;
editingCaption = caption;
CharSequence textToSetWithKeyboard;
@ -5804,6 +5803,9 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
} else {
textToSetWithKeyboard = "";
}
if (draftMessage == null && !hadEditingMessage) {
draftMessage = messageEditText.length() > 0 ? messageEditText.getText() : null;
}
if (!keyboardVisible) {
AndroidUtilities.runOnUIThread(setTextFieldRunnable = () -> {
setFieldText(textToSetWithKeyboard);
@ -5893,7 +5895,8 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
scheduledButton.setAlpha(1.0f);
scheduledButton.setVisibility(VISIBLE);
}
messageEditText.setText("");
messageEditText.setText(draftMessage);
messageEditText.setSelection(messageEditText.length());
if (getVisibility() == VISIBLE) {
delegate.onAttachButtonShow();
}
@ -6094,6 +6097,16 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
return messageEditText;
}
public CharSequence getDraftMessage() {
if (editingMessageObject != null) {
return TextUtils.isEmpty(draftMessage) ? null : draftMessage;
}
if (hasText()) {
return messageEditText.getText();
}
return null;
}
public CharSequence getFieldText() {
if (hasText()) {
return messageEditText.getText();

View File

@ -33,6 +33,7 @@ import android.text.Editable;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.style.ImageSpan;
import android.util.Property;
import android.util.TypedValue;
import android.view.Gravity;
@ -54,6 +55,7 @@ import android.widget.TextView;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ChatObject;
import org.telegram.messenger.ContactsController;
import org.telegram.messenger.Emoji;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaController;
import org.telegram.messenger.MediaDataController;
@ -1422,18 +1424,30 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
commentTextView.onResume();
commentTextView.getEditText().addTextChangedListener(new TextWatcher() {
private boolean processChange;
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
public void onTextChanged(CharSequence charSequence, int start, int before, int count) {
if ((count - before) >= 1) {
processChange = true;
}
}
@Override
public void afterTextChanged(Editable editable) {
if (processChange) {
ImageSpan[] spans = editable.getSpans(0, editable.length(), ImageSpan.class);
for (int i = 0; i < spans.length; i++) {
editable.removeSpan(spans[i]);
}
Emoji.replaceEmoji(editable, commentTextView.getEditText().getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false);
processChange = false;
}
int beforeLimit;
codepointCount = Character.codePointCount(editable, 0, editable.length());
boolean sendButtonEnabledLocal = true;

View File

@ -199,6 +199,11 @@ public class EditTextEmoji extends FrameLayout implements NotificationCenter.Not
if (emojiView != null) {
emojiView.invalidateViews();
}
if (editText != null) {
int color = editText.getCurrentTextColor();
editText.setTextColor(0xffffffff);
editText.setTextColor(color);
}
}
}

View File

@ -16,6 +16,7 @@ import android.animation.StateListAnimator;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.DataSetObserver;
import android.graphics.Canvas;
import android.graphics.Color;
@ -34,6 +35,7 @@ import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.core.view.ViewCompat;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearSmoothScroller;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.SimpleItemAnimator;
@ -66,8 +68,10 @@ import android.widget.PopupWindow;
import android.widget.TextView;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.ChatObject;
import org.telegram.messenger.DocumentObject;
import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.Emoji;
import org.telegram.messenger.EmojiData;
@ -90,6 +94,7 @@ import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.BottomSheet;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Adapters.DialogsSearchAdapter;
import org.telegram.ui.Cells.ContextLinkCell;
import org.telegram.ui.Cells.EmptyCell;
import org.telegram.ui.Cells.FeaturedStickerSetInfoCell;
@ -1656,61 +1661,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
updateStickerTabs();
stickersTab.setDelegate(page -> {
if (page == trendingTabNum) {
final TrendingStickersLayout.Delegate trendingDelegate = new TrendingStickersLayout.Delegate() {
@Override
public void onStickerSetAdd(TLRPC.StickerSetCovered stickerSet, boolean primary) {
delegate.onStickerSetAdd(stickerSet);
if (primary) {
updateStickerTabs();
}
}
@Override
public void onStickerSetRemove(TLRPC.StickerSetCovered stickerSet) {
delegate.onStickerSetRemove(stickerSet);
}
@Override
public boolean onListViewInterceptTouchEvent(RecyclerListView listView, MotionEvent event) {
return ContentPreviewViewer.getInstance().onInterceptTouchEvent(event, listView, EmojiView.this.getMeasuredHeight(), contentPreviewViewerDelegate);
}
@Override
public boolean onListViewTouchEvent(RecyclerListView listView, RecyclerListView.OnItemClickListener onItemClickListener, MotionEvent event) {
return ContentPreviewViewer.getInstance().onTouch(event, listView, EmojiView.this.getMeasuredHeight(), onItemClickListener, contentPreviewViewerDelegate);
}
@Override
public String[] getLastSearchKeyboardLanguage() {
return lastSearchKeyboardLanguage;
}
@Override
public void setLastSearchKeyboardLanguage(String[] language) {
lastSearchKeyboardLanguage = language;
}
@Override
public boolean canSendSticker() {
return true;
}
@Override
public void onStickerSelected(TLRPC.Document sticker, Object parent, boolean clearsInputField, boolean notify, int scheduleDate) {
delegate.onStickerSelected(null, sticker, null, parent, null, notify, scheduleDate);
}
@Override
public boolean canSchedule() {
return delegate.canSchedule();
}
@Override
public boolean isInScheduleMode() {
return delegate.isInScheduleMode();
}
};
this.delegate.showTrendingStickersAlert(new TrendingStickersLayout(context, trendingDelegate, primaryInstallingStickerSets, installingStickerSets, removingStickerSets));
openTrendingStickers(null);
return;
} else if (page == recentTabBum) {
stickersGridView.stopScroll();
@ -2038,6 +1989,64 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
return code;
}
private void openTrendingStickers(TLRPC.StickerSetCovered set) {
final TrendingStickersLayout.Delegate trendingDelegate = new TrendingStickersLayout.Delegate() {
@Override
public void onStickerSetAdd(TLRPC.StickerSetCovered stickerSet, boolean primary) {
delegate.onStickerSetAdd(stickerSet);
if (primary) {
updateStickerTabs();
}
}
@Override
public void onStickerSetRemove(TLRPC.StickerSetCovered stickerSet) {
delegate.onStickerSetRemove(stickerSet);
}
@Override
public boolean onListViewInterceptTouchEvent(RecyclerListView listView, MotionEvent event) {
return ContentPreviewViewer.getInstance().onInterceptTouchEvent(event, listView, EmojiView.this.getMeasuredHeight(), contentPreviewViewerDelegate);
}
@Override
public boolean onListViewTouchEvent(RecyclerListView listView, RecyclerListView.OnItemClickListener onItemClickListener, MotionEvent event) {
return ContentPreviewViewer.getInstance().onTouch(event, listView, EmojiView.this.getMeasuredHeight(), onItemClickListener, contentPreviewViewerDelegate);
}
@Override
public String[] getLastSearchKeyboardLanguage() {
return lastSearchKeyboardLanguage;
}
@Override
public void setLastSearchKeyboardLanguage(String[] language) {
lastSearchKeyboardLanguage = language;
}
@Override
public boolean canSendSticker() {
return true;
}
@Override
public void onStickerSelected(TLRPC.Document sticker, Object parent, boolean clearsInputField, boolean notify, int scheduleDate) {
delegate.onStickerSelected(null, sticker, null, parent, null, notify, scheduleDate);
}
@Override
public boolean canSchedule() {
return delegate.canSchedule();
}
@Override
public boolean isInScheduleMode() {
return delegate.isInScheduleMode();
}
};
this.delegate.showTrendingStickersAlert(new TrendingStickersLayout(getContext(), trendingDelegate, primaryInstallingStickerSets, installingStickerSets, removingStickerSets, set));
}
@Override
public void setTranslationY(float translationY) {
super.setTranslationY(translationY);
@ -2885,7 +2894,9 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
final MediaDataController mediaDataController = MediaDataController.getInstance(currentAccount);
if (!mediaDataController.getFeaturedStickerSets().isEmpty()) {
SharedPreferences preferences = MessagesController.getEmojiSettings(currentAccount);
ArrayList<TLRPC.StickerSetCovered> featured = mediaDataController.getFeaturedStickerSets();
if (!featured.isEmpty() && (!BuildVars.DEBUG_PRIVATE_VERSION || (mediaDataController.getUnreadStickerSets().isEmpty() || preferences.getLong("featured_hidden", 0) == featured.get(0).set.id))) {
final int id = mediaDataController.getUnreadStickerSets().isEmpty() ? 2 : 3;
final ImageView trendingStickersTabView = stickersTab.addIconTab(id, stickerIcons[id]);
trendingStickersTabView.setContentDescription(LocaleController.getString("FeaturedStickers", R.string.FeaturedStickers));
@ -3642,6 +3653,88 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
}
}
private class TrendingAdapter extends RecyclerListView.SelectionAdapter {
@Override
public boolean isEnabled(RecyclerView.ViewHolder holder) {
return true;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
BackupImageView imageView = new BackupImageView(getContext()) {
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
TLRPC.StickerSetCovered set = (TLRPC.StickerSetCovered) getTag();
if (MediaDataController.getInstance(currentAccount).isStickerPackUnread(set.set.id) && dotPaint != null) {
int x = canvas.getWidth() - AndroidUtilities.dp(8);
int y = AndroidUtilities.dp(14);
canvas.drawCircle(x, y, AndroidUtilities.dp(3), dotPaint);
}
}
};
imageView.setSize(AndroidUtilities.dp(30), AndroidUtilities.dp(30));
imageView.setLayerNum(1);
imageView.setAspectFit(true);
imageView.setLayoutParams(new RecyclerView.LayoutParams(AndroidUtilities.dp(52), AndroidUtilities.dp(52)));
return new RecyclerListView.Holder(imageView);
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
BackupImageView imageView = (BackupImageView) holder.itemView;
TLRPC.StickerSetCovered set = MediaDataController.getInstance(currentAccount).getFeaturedStickerSets().get(position);
imageView.setTag(set);
TLRPC.Document document = set.cover;
if (!set.covers.isEmpty()) {
document = set.covers.get(0);
}
TLObject object = FileLoader.getClosestPhotoSizeWithSize(set.set.thumbs, 90);
SvgHelper.SvgDrawable svgThumb = DocumentObject.getSvgThumb(set.set.thumbs, Theme.key_emptyListPlaceholder, 0.2f);
if (object == null) {
object = document;
}
ImageLocation imageLocation;
if (object instanceof TLRPC.Document) {
TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 90);
imageLocation = ImageLocation.getForDocument(thumb, document);
} else if (object instanceof TLRPC.PhotoSize) {
TLRPC.PhotoSize thumb = (TLRPC.PhotoSize) object;
int thumbVersion = set.set.thumb_version;
imageLocation = ImageLocation.getForSticker(thumb, document, thumbVersion);
} else {
return;
}
if (imageLocation == null) {
return;
}
if (object instanceof TLRPC.Document && MessageObject.isAnimatedStickerDocument(document, true)) {
if (svgThumb != null) {
imageView.setImage(ImageLocation.getForDocument(document), "30_30", svgThumb, 0, set);
} else {
imageView.setImage(ImageLocation.getForDocument(document), "30_30", imageLocation, null, 0, set);
}
} else if (imageLocation.imageType == FileLoader.IMAGE_TYPE_LOTTIE) {
imageView.setImage(imageLocation, "30_30", "tgs", svgThumb, set);
} else {
imageView.setImage(imageLocation, null, "webp", svgThumb, set);
}
}
@Override
public int getItemViewType(int position) {
return 0;
}
@Override
public int getItemCount() {
return MediaDataController.getInstance(currentAccount).getFeaturedStickerSets().size();
}
}
private class StickersGridAdapter extends RecyclerListView.SelectionAdapter {
private Context context;
@ -3659,7 +3752,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
@Override
public boolean isEnabled(RecyclerView.ViewHolder holder) {
return false;
return holder.itemView instanceof RecyclerListView;
}
@Override
@ -3689,6 +3782,11 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
if (object instanceof TLRPC.Document) {
return 0;
} else if (object instanceof String) {
if ("trend1".equals(object)) {
return 5;
} else if ("trend2".equals(object)) {
return 6;
}
return 3;
} else {
return 2;
@ -3698,6 +3796,16 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
}
public int getTabForPosition(int position) {
Object cacheObject = cache.get(position);
if ("search".equals(cacheObject) || "trend1".equals(cacheObject) || "trend2".equals(cacheObject)) {
if (favTabBum >= 0) {
return favTabBum;
}
if (recentTabBum >= 0) {
return recentTabBum;
}
return 0;
}
if (position == 0) {
position = 1;
}
@ -3769,6 +3877,49 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
view = new View(context);
view.setLayoutParams(new RecyclerView.LayoutParams(LayoutHelper.MATCH_PARENT, searchFieldHeight));
break;
case 5:
view = new StickerSetNameCell(context, false);
((StickerSetNameCell) view).setOnIconClickListener(v -> {
MediaDataController mediaDataController = MediaDataController.getInstance(currentAccount);
ArrayList<TLRPC.StickerSetCovered> featured = mediaDataController.getFeaturedStickerSets();
if (!featured.isEmpty() && !mediaDataController.getUnreadStickerSets().isEmpty()) {
MessagesController.getEmojiSettings(currentAccount).edit().putLong("featured_hidden", featured.get(0).set.id).commit();
updateStickerTabs();
if (stickersGridAdapter != null) {
stickersGridAdapter.notifyItemRangeRemoved(1, 2);
}
}
});
break;
case 6:
RecyclerListView horizontalListView = new RecyclerListView(context) {
@Override
public boolean onInterceptTouchEvent(MotionEvent e) {
if (getParent() != null && getParent().getParent() != null) {
getParent().getParent().requestDisallowInterceptTouchEvent(canScrollHorizontally(-1) || canScrollHorizontally(1));
pager.requestDisallowInterceptTouchEvent(true);
}
return super.onInterceptTouchEvent(e);
}
};
horizontalListView.setTag(9);
horizontalListView.setItemAnimator(null);
horizontalListView.setLayoutAnimation(null);
LinearLayoutManager layoutManager = new LinearLayoutManager(context) {
@Override
public boolean supportsPredictiveItemAnimations() {
return false;
}
};
layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
horizontalListView.setLayoutManager(layoutManager);
horizontalListView.setAdapter(new TrendingAdapter());
horizontalListView.setOnItemClickListener((view1, position) -> {
openTrendingStickers((TLRPC.StickerSetCovered) view1.getTag());
});
view = horizontalListView;
view.setLayoutParams(new RecyclerView.LayoutParams(LayoutHelper.MATCH_PARENT, AndroidUtilities.dp(52)));
break;
}
return new RecyclerListView.Holder(view);
@ -3851,15 +4002,20 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
cell.setIsLast(position == totalItems - 1);
break;
}
case 5: {
StickerSetNameCell cell = (StickerSetNameCell) holder.itemView;
cell.setText(LocaleController.getString("FeaturedStickers", R.string.FeaturedStickers), R.drawable.stickerset_close);
break;
}
}
}
@Override
public void notifyDataSetChanged() {
private void updateItems() {
int width = getMeasuredWidth();
if (width == 0) {
width = AndroidUtilities.displaySize.x;
}
stickersPerRow = width / AndroidUtilities.dp(72);
stickersLayoutManager.setSpanCount(stickersPerRow);
rowStartPack.clear();
@ -3869,14 +4025,24 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
totalItems = 0;
ArrayList<TLRPC.TL_messages_stickerSet> packs = stickerSets;
int startRow = 0;
for (int a = -3; a < packs.size(); a++) {
for (int a = -4; a < packs.size(); a++) {
ArrayList<TLRPC.Document> documents;
TLRPC.TL_messages_stickerSet pack = null;
String key;
if (a == -3) {
if (a == -4) {
cache.put(totalItems++, "search");
startRow++;
continue;
} else if (a == -3) {
MediaDataController mediaDataController = MediaDataController.getInstance(currentAccount);
SharedPreferences preferences = MessagesController.getEmojiSettings(currentAccount);
ArrayList<TLRPC.StickerSetCovered> featured = mediaDataController.getFeaturedStickerSets();
if (BuildVars.DEBUG_PRIVATE_VERSION && !featured.isEmpty() && !mediaDataController.getUnreadStickerSets().isEmpty() && preferences.getLong("featured_hidden", 0) != featured.get(0).set.id) {
cache.put(totalItems++, "trend1");
cache.put(totalItems++, "trend2");
startRow += 2;
}
continue;
} else if (a == -2) {
documents = favouriteStickers;
packStartPosition.put(key = "fav", totalItems);
@ -3931,6 +4097,17 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
totalItems += count * stickersPerRow + 1;
startRow += count + 1;
}
}
@Override
public void notifyItemRangeRemoved(int positionStart, int itemCount) {
updateItems();
super.notifyItemRangeRemoved(positionStart, itemCount);
}
@Override
public void notifyDataSetChanged() {
updateItems();
super.notifyDataSetChanged();
}
}

View File

@ -270,10 +270,11 @@ public class GroupVoipInviteAlert extends UsersAlertBase {
continue;
}
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(participant.user_id);
if (user == null || !user.bot) {
participants.add(participant);
participantsMap.put(participant.user_id, participant);
if (UserObject.isDeleted(user) || user.bot) {
continue;
}
participants.add(participant);
participantsMap.put(participant.user_id, participant);
}
if (participants.isEmpty()) {
showContacts = true;
@ -347,7 +348,7 @@ public class GroupVoipInviteAlert extends UsersAlertBase {
remove = true;
}
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(peerId);
if (user != null && user.bot) {
if (user != null && user.bot || UserObject.isDeleted(user)) {
remove = true;
}
if (remove) {

View File

@ -140,7 +140,7 @@ public class JoinCallAlert extends BottomSheet {
}
textView[a].setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
textView[a].setPadding(0, 0, 0, hasBackground ? 0 : AndroidUtilities.dp(13));
addView(textView[a], LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
addView(textView[a], LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 24, 0, 24, 0));
if (a == 1) {
textView[a].setAlpha(0.0f);
}

View File

@ -38,6 +38,7 @@ import org.telegram.ui.Cells.GraySectionCell;
import org.telegram.ui.Cells.StickerEmojiCell;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class TrendingStickersLayout extends FrameLayout implements NotificationCenter.NotificationCenterDelegate {
@ -112,17 +113,19 @@ public class TrendingStickersLayout extends FrameLayout implements NotificationC
ValueAnimator glueToTopAnimator;
private boolean gluedToTop;
private boolean scrollFromAnimator;
private TLRPC.StickerSetCovered scrollToSet;
public TrendingStickersLayout(@NonNull Context context, Delegate delegate) {
this(context, delegate, new TLRPC.StickerSetCovered[10], new LongSparseArray<>(), new LongSparseArray<>());
this(context, delegate, new TLRPC.StickerSetCovered[10], new LongSparseArray<>(), new LongSparseArray<>(), null);
}
public TrendingStickersLayout(@NonNull Context context, Delegate delegate, TLRPC.StickerSetCovered[] primaryInstallingStickerSets, LongSparseArray<TLRPC.StickerSetCovered> installingStickerSets, LongSparseArray<TLRPC.StickerSetCovered> removingStickerSets) {
public TrendingStickersLayout(@NonNull Context context, Delegate delegate, TLRPC.StickerSetCovered[] primaryInstallingStickerSets, LongSparseArray<TLRPC.StickerSetCovered> installingStickerSets, LongSparseArray<TLRPC.StickerSetCovered> removingStickerSets, TLRPC.StickerSetCovered scrollToSet) {
super(context);
this.delegate = delegate;
this.primaryInstallingStickerSets = primaryInstallingStickerSets;
this.installingStickerSets = installingStickerSets;
this.removingStickerSets = removingStickerSets;
this.scrollToSet = scrollToSet;
this.adapter = new TrendingStickersAdapter(context);
final StickersSearchAdapter.Delegate searchAdapterDelegate = new StickersSearchAdapter.Delegate() {
@ -346,6 +349,12 @@ public class TrendingStickersLayout extends FrameLayout implements NotificationC
if (!wasLayout) {
wasLayout = true;
adapter.refreshStickerSets();
if (scrollToSet != null) {
Integer pos = adapter.setsToPosition.get(scrollToSet);
if (pos != null) {
layoutManager.scrollToPositionWithOffset(pos, -listView.getPaddingTop() + AndroidUtilities.dp(58));
}
}
}
}
@ -591,6 +600,7 @@ public class TrendingStickersLayout extends FrameLayout implements NotificationC
private final SparseArray<Object> cache = new SparseArray<>();
private final ArrayList<TLRPC.StickerSetCovered> sets = new ArrayList<>();
private final SparseArray<TLRPC.StickerSetCovered> positionsToSets = new SparseArray<>();
private final HashMap<TLRPC.StickerSetCovered, Integer> setsToPosition = new HashMap<>();
private final ArrayList<TLRPC.StickerSetCovered> otherPacks = new ArrayList<>();
private boolean loadingMore;
@ -826,6 +836,7 @@ public class TrendingStickersLayout extends FrameLayout implements NotificationC
}
cache.clear();
positionsToSets.clear();
setsToPosition.clear();
sets.clear();
totalItems = 0;
int num = 0;
@ -847,6 +858,7 @@ public class TrendingStickersLayout extends FrameLayout implements NotificationC
sets.add(pack);
positionsToSets.put(totalItems, pack);
setsToPosition.put(pack, totalItems);
cache.put(totalItems++, num++);
int count;

View File

@ -54,6 +54,8 @@ import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.PaymentFormActivity;
import java.util.ArrayList;
@SuppressWarnings("FieldCanBeLocal")
public class UndoView extends FrameLayout {
@ -82,7 +84,7 @@ public class UndoView extends FrameLayout {
private int textWidth;
private int currentAction;
private long currentDialogId;
private ArrayList<Long> currentDialogIds;
private Runnable currentActionRunnable;
private Runnable currentCancelRunnable;
@ -120,6 +122,8 @@ public class UndoView extends FrameLayout {
public final static int ACTION_CHAT_UNARCHIVED = 23;
public final static int ACTION_PROXIMITY_SET = 24;
public final static int ACTION_PROXIMITY_REMOVED = 25;
public final static int ACTION_CLEAR_FEW = 26;
public final static int ACTION_DELETE_FEW = 27;
public final static int ACTION_VOIP_MUTED = 30;
public final static int ACTION_VOIP_UNMUTED = 31;
@ -353,9 +357,12 @@ public class UndoView extends FrameLayout {
}
currentCancelRunnable = null;
}
if (currentAction == ACTION_CLEAR || currentAction == ACTION_DELETE) {
MessagesController.getInstance(currentAccount).removeDialogAction(currentDialogId, currentAction == ACTION_CLEAR, apply);
onRemoveDialogAction(currentDialogId, currentAction);
if (currentAction == ACTION_CLEAR || currentAction == ACTION_DELETE || currentAction == ACTION_CLEAR_FEW || currentAction == ACTION_DELETE_FEW) {
for (int a = 0; a < currentDialogIds.size(); a++) {
long did = currentDialogIds.get(a);
MessagesController.getInstance(currentAccount).removeDialogAction(did, currentAction == ACTION_CLEAR || currentAction == ACTION_CLEAR_FEW, apply);
onRemoveDialogAction(did, currentAction);
}
}
if (animated != 0) {
AnimatorSet animatorSet = new AnimatorSet();
@ -411,13 +418,20 @@ public class UndoView extends FrameLayout {
}
public void showWithAction(long did, int action, Object infoObject, Object infoObject2, Runnable actionRunnable, Runnable cancelRunnable) {
ArrayList<Long> ids = new ArrayList<>();
ids.add(did);
showWithAction(ids, action, infoObject, infoObject2, actionRunnable, cancelRunnable);
}
public void showWithAction(ArrayList<Long> dialogIds, int action, Object infoObject, Object infoObject2, Runnable actionRunnable, Runnable cancelRunnable) {
if (currentActionRunnable != null) {
currentActionRunnable.run();
}
isShown = true;
currentActionRunnable = actionRunnable;
currentCancelRunnable = cancelRunnable;
currentDialogId = did;
currentDialogIds = dialogIds;
long did = dialogIds.get(0);
currentAction = action;
timeLeft = 5000;
currentInfoObject = infoObject;
@ -1264,8 +1278,10 @@ public class UndoView extends FrameLayout {
subinfoTextView.setVisibility(GONE);
leftImageView.setVisibility(GONE);
if (currentAction == ACTION_CLEAR) {
if (currentAction == ACTION_CLEAR || currentAction == ACTION_CLEAR_FEW) {
infoTextView.setText(LocaleController.getString("HistoryClearedUndo", R.string.HistoryClearedUndo));
} else if (currentAction == ACTION_DELETE_FEW) {
infoTextView.setText(LocaleController.getString("ChatsDeletedUndo", R.string.ChatsDeletedUndo));
} else {
int lowerId = (int) did;
if (lowerId < 0) {
@ -1279,7 +1295,9 @@ public class UndoView extends FrameLayout {
infoTextView.setText(LocaleController.getString("ChatDeletedUndo", R.string.ChatDeletedUndo));
}
}
MessagesController.getInstance(currentAccount).addDialogAction(did, currentAction == ACTION_CLEAR);
for (int a = 0; a < dialogIds.size(); a++) {
MessagesController.getInstance(currentAccount).addDialogAction(dialogIds.get(a), currentAction == ACTION_CLEAR || currentAction == ACTION_CLEAR_FEW);
}
}
AndroidUtilities.makeAccessibilityAnnouncement(infoTextView.getText() + (subinfoTextView.getVisibility() == VISIBLE ? ". " + subinfoTextView.getText() : ""));
@ -1372,7 +1390,7 @@ public class UndoView extends FrameLayout {
backgroundDrawable.draw(canvas);
}
if (currentAction == ACTION_DELETE || currentAction == ACTION_CLEAR) {
if (currentAction == ACTION_DELETE || currentAction == ACTION_CLEAR || currentAction == ACTION_DELETE_FEW || currentAction == ACTION_CLEAR_FEW) {
int newSeconds = timeLeft > 0 ? (int) Math.ceil(timeLeft / 1000.0f) : 0;
if (prevSeconds != newSeconds) {
prevSeconds = newSeconds;

View File

@ -1374,7 +1374,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
ArrayList<Long> selectedDialogs = new ArrayList<>();
selectedDialogs.add(dialogId);
canReadCount = dialog.unread_count > 0 || dialog.unread_mark ? 1 : 0;
perfromSelectedDialogsAction(selectedDialogs, read, true);
performSelectedDialogsAction(selectedDialogs, read, true);
} else if (SharedConfig.getChatSwipeAction(currentAccount) == SwipeGestureSettingsView.SWIPE_GESTURE_MUTE) {
if (!getMessagesController().isDialogMuted(dialogId)) {
NotificationsController.getInstance(UserConfig.selectedAccount).setDialogNotificationsSettings(dialogId, NotificationsController.SETTING_MUTE_FOREVER);
@ -1386,18 +1386,18 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
selectedDialogs.add(dialogId);
canMuteCount = MessagesController.getInstance(currentAccount).isDialogMuted(dialogId) ? 0 : 1;
canUnmuteCount = canMuteCount > 0 ? 0 : 1;
perfromSelectedDialogsAction(selectedDialogs, mute, true);
performSelectedDialogsAction(selectedDialogs, mute, true);
}
} else if (SharedConfig.getChatSwipeAction(currentAccount) == SwipeGestureSettingsView.SWIPE_GESTURE_PIN) {
ArrayList<Long> selectedDialogs = new ArrayList<>();
selectedDialogs.add(dialogId);
boolean pinned = isDialogPinned(dialog);
canPinCount = pinned ? 0 : 1;
perfromSelectedDialogsAction(selectedDialogs, pin, true);
performSelectedDialogsAction(selectedDialogs, pin, true);
} else if (SharedConfig.getChatSwipeAction(currentAccount) == SwipeGestureSettingsView.SWIPE_GESTURE_DELETE) {
ArrayList<Long> selectedDialogs = new ArrayList<>();
selectedDialogs.add(dialogId);
perfromSelectedDialogsAction(selectedDialogs, delete, true);
performSelectedDialogsAction(selectedDialogs, delete, true);
}
}
}
@ -1588,7 +1588,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
ArrayList<Long> selectedDialogs = new ArrayList<>();
selectedDialogs.add(dialogId);
canReadCount = dialog.unread_count > 0 || dialog.unread_mark ? 1 : 0;
perfromSelectedDialogsAction(selectedDialogs, read, true);
performSelectedDialogsAction(selectedDialogs, read, true);
return;
}
@ -3424,7 +3424,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
@Override
protected void onRemoveDialogAction(long currentDialogId, int action) {
if (action == UndoView.ACTION_DELETE) {
if (action == UndoView.ACTION_DELETE || action == UndoView.ACTION_DELETE_FEW) {
debugLastUpdateAction = 1;
setDialogsListFrozen(true);
if (frozenDialogsList != null) {
@ -3826,7 +3826,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
getUndoView().showWithAction(did, UndoView.ACTION_REMOVED_FROM_FOLDER, neverShow.size(), filter, null, null);
hideActionMode(false);
} else if (id == pin || id == read || id == delete || id == clear || id == mute || id == archive || id == block || id == archive2 || id == pin2) {
perfromSelectedDialogsAction(selectedDialogs, id, true);
performSelectedDialogsAction(selectedDialogs, id, true);
}
}
});
@ -5227,7 +5227,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
return dialog.pinned;
}
private void perfromSelectedDialogsAction(ArrayList<Long> selectedDialogs, int action, boolean alert) {
private void performSelectedDialogsAction(ArrayList<Long> selectedDialogs, int action, boolean alert) {
if (getParentActivity() == null) {
return;
}
@ -5336,28 +5336,37 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (action == delete) {
builder.setTitle(LocaleController.formatString("DeleteFewChatsTitle", R.string.DeleteFewChatsTitle, LocaleController.formatPluralString("ChatsSelected", count)));
builder.setMessage(LocaleController.getString("AreYouSureDeleteFewChats", R.string.AreYouSureDeleteFewChats));
builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialog1, which) -> {
getMessagesController().setDialogsInTransaction(true);
perfromSelectedDialogsAction(selectedDialogs, action, false);
getMessagesController().setDialogsInTransaction(false);
getMessagesController().checkIfFolderEmpty(folderId);
if (folderId != 0 && getDialogsArray(currentAccount, viewPages[0].dialogsType, folderId, false).size() == 0) {
viewPages[0].listView.setEmptyView(null);
viewPages[0].progressView.setVisibility(View.INVISIBLE);
finishFragment();
}
});
} else {
if (canClearCacheCount != 0) {
builder.setTitle(LocaleController.formatString("ClearCacheFewChatsTitle", R.string.ClearCacheFewChatsTitle, LocaleController.formatPluralString("ChatsSelectedClearCache", count)));
builder.setMessage(LocaleController.getString("AreYouSureClearHistoryCacheFewChats", R.string.AreYouSureClearHistoryCacheFewChats));
builder.setPositiveButton(LocaleController.getString("ClearHistoryCache", R.string.ClearHistoryCache), (dialog1, which) -> perfromSelectedDialogsAction(selectedDialogs, action, false));
} else {
builder.setTitle(LocaleController.formatString("ClearFewChatsTitle", R.string.ClearFewChatsTitle, LocaleController.formatPluralString("ChatsSelectedClear", count)));
builder.setMessage(LocaleController.getString("AreYouSureClearHistoryFewChats", R.string.AreYouSureClearHistoryFewChats));
builder.setPositiveButton(LocaleController.getString("ClearHistory", R.string.ClearHistory), (dialog1, which) -> perfromSelectedDialogsAction(selectedDialogs, action, false));
}
}
builder.setPositiveButton(action == delete ? LocaleController.getString("Delete", R.string.Delete)
: canClearCacheCount != 0 ? LocaleController.getString("ClearHistoryCache", R.string.ClearHistoryCache)
: LocaleController.getString("ClearHistory", R.string.ClearHistory)
, (dialog1, which) -> {
ArrayList<Long> didsCopy = new ArrayList<>(selectedDialogs);
getUndoView().showWithAction(didsCopy, action == delete ? UndoView.ACTION_DELETE_FEW : UndoView.ACTION_CLEAR_FEW, null, null, () -> {
if (action == delete) {
getMessagesController().setDialogsInTransaction(true);
performSelectedDialogsAction(didsCopy, action, false);
getMessagesController().setDialogsInTransaction(false);
getMessagesController().checkIfFolderEmpty(folderId);
if (folderId != 0 && getDialogsArray(currentAccount, viewPages[0].dialogsType, folderId, false).size() == 0) {
viewPages[0].listView.setEmptyView(null);
viewPages[0].progressView.setVisibility(View.INVISIBLE);
finishFragment();
}
} else {
performSelectedDialogsAction(didsCopy, action, false);
}
}, null);
hideActionMode(action == clear);
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
AlertDialog alertDialog = builder.create();
showDialog(alertDialog);
@ -5522,30 +5531,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
}
}
getUndoView().showWithAction(selectedDialog, action == clear ? UndoView.ACTION_CLEAR : UndoView.ACTION_DELETE, () -> {
if (action == clear) {
getMessagesController().deleteDialog(selectedDialog, 1, param);
} else {
if (chat != null) {
if (ChatObject.isNotInChat(chat)) {
getMessagesController().deleteDialog(selectedDialog, 0, param);
} else {
TLRPC.User currentUser = getMessagesController().getUser(getUserConfig().getClientUserId());
getMessagesController().deleteParticipantFromChat((int) -selectedDialog, currentUser, null, null, param, false);
}
} else {
getMessagesController().deleteDialog(selectedDialog, 0, param);
if (isBot) {
getMessagesController().blockPeer((int) selectedDialog);
}
}
if (AndroidUtilities.isTablet()) {
getNotificationCenter().postNotificationName(NotificationCenter.closeChats, selectedDialog);
}
getMessagesController().checkIfFolderEmpty(folderId);
}
});
getUndoView().showWithAction(selectedDialog, action == clear ? UndoView.ACTION_CLEAR : UndoView.ACTION_DELETE, () -> performDeleteOrClearDialogAction(action, selectedDialog, chat, isBot, param));
ArrayList<TLRPC.Dialog> currentDialogs = new ArrayList<>(getDialogsArray(currentAccount, viewPages[0].dialogsType, folderId, false));
int currentDialogIndex = -1;
@ -5577,26 +5563,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (action == clear && canClearCacheCount != 0) {
getMessagesController().deleteDialog(selectedDialog, 2, false);
} else {
if (action == clear) {
getMessagesController().deleteDialog(selectedDialog, 1, false);
} else {
if (chat != null) {
if (ChatObject.isNotInChat(chat)) {
getMessagesController().deleteDialog(selectedDialog, 0, false);
} else {
TLRPC.User currentUser = getMessagesController().getUser(getUserConfig().getClientUserId());
getMessagesController().deleteParticipantFromChat((int) -selectedDialog, currentUser, null);
}
} else {
getMessagesController().deleteDialog(selectedDialog, 0, false);
if (isBot) {
getMessagesController().blockPeer((int) selectedDialog);
}
}
if (AndroidUtilities.isTablet()) {
getNotificationCenter().postNotificationName(NotificationCenter.closeChats, selectedDialog);
}
}
performDeleteOrClearDialogAction(action, selectedDialog, chat, isBot, false);
}
}
}
@ -5641,6 +5608,30 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
hideActionMode(action != pin2 && action != pin && action != delete);
}
private void performDeleteOrClearDialogAction(int action, long selectedDialog, TLRPC.Chat chat, boolean isBot, boolean revoke) {
if (action == clear) {
getMessagesController().deleteDialog(selectedDialog, 1, revoke);
} else {
if (chat != null) {
if (ChatObject.isNotInChat(chat)) {
getMessagesController().deleteDialog(selectedDialog, 0, revoke);
} else {
TLRPC.User currentUser = getMessagesController().getUser(getUserConfig().getClientUserId());
getMessagesController().deleteParticipantFromChat((int) -selectedDialog, currentUser, null, null, revoke, false);
}
} else {
getMessagesController().deleteDialog(selectedDialog, 0, revoke);
if (isBot) {
getMessagesController().blockPeer((int) selectedDialog);
}
}
if (AndroidUtilities.isTablet()) {
getNotificationCenter().postNotificationName(NotificationCenter.closeChats, selectedDialog);
}
getMessagesController().checkIfFolderEmpty(folderId);
}
}
private void pinDialog(long selectedDialog, boolean pin, MessagesController.DialogFilter filter, int minPinnedNum, boolean animated) {
int selectedDialogIndex = -1;

View File

@ -2709,6 +2709,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
SharedConfig.setNoSoundHintShowed(false);
SharedPreferences.Editor editor = MessagesController.getGlobalMainSettings().edit();
editor.remove("archivehint").remove("proximityhint").remove("archivehint_l").remove("gifhint").remove("reminderhint").remove("soundHint").remove("themehint").remove("filterhint").commit();
MessagesController.getEmojiSettings(currentAccount).edit().remove("featured_hidden").commit();
SharedConfig.textSelectionHintShows = 0;
SharedConfig.lockRecordAudioVideoHint = 0;
SharedConfig.stickersReorderingHintUsed = false;

View File

@ -169,6 +169,7 @@
<string name="AutoDeleteSetTimer">Set auto-delete timer</string>
<string name="AccAutoDeleteTimer">Auto-delete timer</string>
<string name="HistoryClearedUndo">History cleared.</string>
<string name="ChatsDeletedUndo">Chats deleted.</string>
<string name="ChatsMute">Mute</string>
<string name="ChatsUnmute">Unmute</string>
<string name="ChatDeletedUndo">Chat deleted</string>
@ -894,14 +895,20 @@
<string name="InstantViewNightMode">The dark theme will turn automatically during night time</string>
<string name="InstantViewReference">Reference</string>
<string name="IsSendingGame">%1$s is playing a game...</string>
<string name="IsSelectingLocation">%1$s is selecting location to share...</string>
<string name="IsSelectingContact">%1$s is selecting contact to share...</string>
<string name="IsSendingVideo">%1$s is sending video...</string>
<string name="IsRecordingVideo">%1$s is recording video...</string>
<string name="IsSendingFile">%1$s is sending file...</string>
<string name="RecordingAudio">recording a voice message...</string>
<string name="RecordingRound">recording a video message...</string>
<string name="SendingAudio">sending audio...</string>
<string name="SendingPhoto">sending a photo...</string>
<string name="SendingGame">playing a game...</string>
<string name="SelectingLocation">selecting a location to share...</string>
<string name="SelectingContact">selecting a contact to share...</string>
<string name="SendingVideoStatus">sending a video...</string>
<string name="RecordingVideoStatus">recording a video...</string>
<string name="SendingFile">sending a file...</string>
<string name="GotAQuestion">Got a question\nabout Telegram?</string>
<string name="ChatGallery">Gallery</string>