Merge pull request #561 from wrwrabbit/fixes/4.2.0

Fixes/4.2.0
This commit is contained in:
vivabelarus 2025-06-09 22:25:04 +00:00 committed by GitHub
commit a4701ce6dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 375 additions and 255 deletions

View file

@ -18,7 +18,7 @@ jobs:
- name: Save artifact
uses: actions/upload-artifact@master
with:
name: PTelegramAlpha-1619.apk
name: PTelegramAlpha-1622.apk
path: TMessagesProj/build/outputs/apk/afat/alpha/app.apk
- name: Create cleanup request
run: touch delete_request

View file

@ -305,4 +305,5 @@
<string name="EncryptedGroupMemberRemovalConfirmation">Вы ўпэўненыя, што жадаеце выдаліць гэтага ўдзельніка з сакрэтнай групы? Усе яго паведамленні будуць выдалены.</string>
<string name="EncryptedGroupAvatarChangeForbidden">Нельга змяніць аватар да ініцыялізацыі групы.</string>
<string name="CantAddNewMemberToEncryptedGroupMessage">Неабходна дачакацца пацверджання ад папярэдніх чальцоў перад даданнем новага.</string>
<string name="SlowSecretGroupCreationWarning">Сакрэтная група на 7 і больш удзельнікаў будзе стварацца даўжэй, чым звычайна.</string>
</resources>

View file

@ -304,4 +304,5 @@
<string name="EncryptedGroupMemberRemovalConfirmation">Вы уверены, что хотите удалить этого участника из секретной группы? Все его сообщения будут удалены.</string>
<string name="EncryptedGroupAvatarChangeForbidden">Нельзя изменить аватар до инициализации группы.</string>
<string name="CantAddNewMemberToEncryptedGroupMessage">Необходимо дождаться подтверждения от предыдущих членов перед добавлением нового.</string>
<string name="SlowSecretGroupCreationWarning">Секретная группа на 7 и более участников будет создаваться дольше обычного.</string>
</resources>

View file

@ -305,4 +305,5 @@
<string name="EncryptedGroupMemberRemovalConfirmation">Ви впевнені, що хочете видалити цього учасника із секретної групи? Усі його повідомлення будуть видалені.</string>
<string name="EncryptedGroupAvatarChangeForbidden">Не можна змінити аватар до ініціалізації групи.</string>
<string name="CantAddNewMemberToEncryptedGroupMessage">Перед додаванням нового необхідно дочекатися підтвердження від попередніх членів.</string>
<string name="SlowSecretGroupCreationWarning">Секретна група на 7 і більше учасників буде створюватися довше, ніж зазвичай.</string>
</resources>

View file

@ -60,7 +60,6 @@ import org.telegram.SQLite.SQLitePreparedStatement;
import org.telegram.messenger.browser.Browser;
import org.telegram.messenger.partisan.messageinterception.PartisanMessagesInterceptionController;
import org.telegram.messenger.partisan.secretgroups.EncryptedGroup;
import org.telegram.messenger.partisan.secretgroups.InnerEncryptedChat;
import org.telegram.messenger.support.LongSparseIntArray;
import org.telegram.messenger.support.LongSparseLongArray;
import org.telegram.messenger.voip.VoIPPreNotificationService;
@ -14130,7 +14129,7 @@ public class MessagesController extends BaseController implements NotificationCe
if (!DialogObject.isEncryptedDialog(dialogId)) {
return;
}
if (getEncryptedGroupUtils().doForEachInnerDialogIdIfNeeded(dialogId, innerDialogId -> markMessageAsRead(innerDialogId, randomId, ttl))) {
if (getEncryptedGroupUtils().forEachInnerDialogIdIfEncryptedGroup(dialogId, innerDialogId -> markMessageAsRead(innerDialogId, randomId, ttl))) {
return;
}
TLRPC.EncryptedChat chat = getEncryptedChat(DialogObject.getEncryptedChatId(dialogId));
@ -14263,7 +14262,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
public void markDialogAsRead(long dialogId, int maxPositiveId, int maxNegativeId, int maxDate, boolean popup, long threadId, int countDiff, boolean readNow, int scheduledCount) {
getEncryptedGroupUtils().doForEachInnerDialogIdIfNeeded(dialogId, innerDialogId ->
getEncryptedGroupUtils().forEachInnerDialogIdIfEncryptedGroup(dialogId, innerDialogId ->
markDialogAsRead(innerDialogId, maxPositiveId, maxNegativeId, maxDate, popup, threadId, countDiff, readNow, scheduledCount)
);
boolean createReadTask;

View file

@ -1291,7 +1291,7 @@ public class MessagesStorage extends BaseController {
storageQueue.postRunnable(() -> resetAllUnreadCounters(true));
}
public void removeChatsActionExecuted() {
public void unreadCounterChangedByFakePasscode() {
for (int a = 0, N = dialogFilters.size(); a < N; a++) {
MessagesController.DialogFilter filter = dialogFilters.get(a);
filter.pendingUnreadCount = -1;
@ -2855,7 +2855,8 @@ public class MessagesStorage extends BaseController {
if (!encryptedGroupsToLoad.isEmpty()) {
List<EncryptedGroup> encryptedGroups = getEncryptedGroupsInternal(encryptedGroupsToLoad);
for (EncryptedGroup encryptedGroup : encryptedGroups) {
if (FakePasscodeUtils.isHideChat(DialogObject.makeEncryptedDialogId(encryptedGroup.getInternalId()), currentAccount)) {
if (FakePasscodeUtils.isHideChat(DialogObject.makeEncryptedDialogId(encryptedGroup.getInternalId()), currentAccount)
|| FakePasscodeUtils.isFakePasscodeActivated()) {
continue;
}
long did = DialogObject.makeEncryptedDialogId(encryptedGroup.getInternalId());
@ -5947,7 +5948,8 @@ public class MessagesStorage extends BaseController {
if (!encryptedGroupsToLoad.isEmpty()) {
List<EncryptedGroup> encryptedGroups = getEncryptedGroupsInternal(encryptedGroupsToLoad);
for (EncryptedGroup encryptedGroup : encryptedGroups) {
if (FakePasscodeUtils.isHideChat(DialogObject.makeEncryptedDialogId(encryptedGroup.getInternalId()), currentAccount)) {
if (FakePasscodeUtils.isHideChat(DialogObject.makeEncryptedDialogId(encryptedGroup.getInternalId()), currentAccount)
|| FakePasscodeUtils.isFakePasscodeActivated()) {
continue;
}
long did = DialogObject.makeEncryptedDialogId(encryptedGroup.getInternalId());

View file

@ -6325,7 +6325,7 @@ public class NotificationsController extends BaseController {
}
private boolean doForEachInnerDialogIdIfNeeded(long encryptedGroupDialogId, Consumer<Long> action) {
return getEncryptedGroupUtils().doForEachInnerDialogIdIfNeeded(encryptedGroupDialogId, action);
return getEncryptedGroupUtils().forEachInnerDialogIdIfEncryptedGroup(encryptedGroupDialogId, action);
}
private String getTitle(TLRPC.Chat chat) {

View file

@ -1124,7 +1124,7 @@ public class SecretChatHelper extends BaseController {
chat.ttl = serviceMessage.action.ttl_seconds;
newMessage.action.encryptedAction = serviceMessage.action;
getMessagesStorage().updateEncryptedChatTTL(chat);
getEncryptedGroupUtils().syncTtlIfNeeded(chat);
getEncryptedGroupUtils().syncTtlWithOtherMembersIfNeeded(chat);
} else {
newMessage.action = new TLRPC.TL_messageEncryptedAction();
newMessage.action.encryptedAction = serviceMessage.action;

View file

@ -5608,7 +5608,11 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
}
if (sendMessageParams.autoDeleteDelay != null) {
RemoveAsReadMessage messageToRemove = new RemoveAsReadMessage(newMsg.id, MessageObject.getTopicId(currentAccount, newMsg, false), newMsg.random_id, newMsg.date, sendMessageParams.autoDeleteDelay);
long topicId = MessageObject.getTopicId(currentAccount, newMsg, false);
if (topicId == 0 && replyToMsg != null && replyToMsg.isTopicMainMessage) {
topicId = replyToMsg.getTopicId();
}
RemoveAsReadMessage messageToRemove = new RemoveAsReadMessage(newMsg.id, topicId, newMsg.random_id, newMsg.date, sendMessageParams.autoDeleteDelay);
RemoveAfterReadingMessages.addMessageToRemove(currentAccount, newMsg.dialog_id, messageToRemove);
}
}

View file

@ -1219,6 +1219,7 @@ public class SharedConfig {
if (!overriddenDialogIds.isEmpty()) {
MessagesStorage.getInstance(i).updateOverriddenWidgets(overriddenDialogIds);
}
MessagesStorage.getInstance(i).unreadCounterChangedByFakePasscode();
}
}
FakePasscode passcode = FakePasscodeUtils.getActivatedFakePasscode();

View file

@ -3,12 +3,10 @@ package org.telegram.messenger.fakepasscode;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.android.exoplayer2.util.Log;
import com.google.common.collect.Lists;
import org.telegram.messenger.AccountInstance;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.BuildConfig;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaDataController;
@ -20,6 +18,7 @@ import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.messenger.fakepasscode.results.ActionsResult;
import org.telegram.messenger.fakepasscode.results.RemoveChatsResult;
import org.telegram.messenger.partisan.PartisanLog;
import org.telegram.messenger.partisan.Utils;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLRPC;
@ -94,8 +93,7 @@ public class FakePasscode {
return base + " " + (SharedConfig.fakePasscodeIndex);
}
List<Action> actions()
{
private List<Action> getAllActions() {
List<Action> result = new ArrayList<>(Arrays.asList(clearCacheAction, clearDownloadsAction, smsAction));
result.addAll(accountActions);
result.add(clearProxiesAction);
@ -106,7 +104,7 @@ public class FakePasscode {
public AccountActions getAccountActions(int accountNum) {
for (AccountActions actions : accountActions) {
Integer actionsAccountNum = actions.getAccountNum();
if (actionsAccountNum != null && actionsAccountNum == accountNum) {
if (Objects.equals(actionsAccountNum, accountNum)) {
return actions;
}
}
@ -114,15 +112,12 @@ public class FakePasscode {
}
public AccountActions getOrCreateAccountActions(int accountNum) {
for (AccountActions actions : accountActions) {
Integer actionsAccountNum = actions.getAccountNum();
if (actionsAccountNum != null && actionsAccountNum == accountNum) {
return actions;
}
AccountActions actions = getAccountActions(accountNum);
if (actions == null) {
actions = new AccountActions();
actions.setAccountNum(accountNum);
accountActions.add(actions);
}
AccountActions actions = new AccountActions();
actions.setAccountNum(accountNum);
accountActions.add(actions);
return actions;
}
@ -151,18 +146,16 @@ public class FakePasscode {
actionsResult.setActivated();
SharedConfig.fakePasscodeActionsResult = actionsResult;
SharedConfig.saveConfig();
for (Action action : actions()) {
for (Action action : getAllActions()) {
action.setExecutionScheduled();
}
Utils.runOnUIThreadAsSoonAsPossible(() -> {
activated = true;
for (Action action : actions()) {
for (Action action : getAllActions()) {
try {
action.execute(this);
} catch (Exception e) {
if (BuildConfig.DEBUG) {
Log.e("FakePasscode", "Error", e);
}
PartisanLog.e("FakePasscode error", e);
}
}
checkClearAfterActivation();
@ -191,7 +184,7 @@ public class FakePasscode {
}
NotificationCenter notificationCenter = NotificationCenter.getInstance(account);
if (!removeResult.hiddenChatEntries.isEmpty()) {
MessagesStorage.getInstance(account).removeChatsActionExecuted();
MessagesStorage.getInstance(account).unreadCounterChangedByFakePasscode();
notificationCenter.postNotificationName(NotificationCenter.dialogsHidingChanged);
}
if (!removeResult.hiddenFolders.isEmpty()) {
@ -249,7 +242,7 @@ public class FakePasscode {
deletePasscodesAfterActivation.setSelected(Collections.emptyList());
}
deleteOtherPasscodesAfterActivation = null;
actions().stream().forEach(Action::migrate);
getAllActions().stream().forEach(Action::migrate);
if (actionsResult != null) {
actionsResult.migrate();
}
@ -285,12 +278,12 @@ public class FakePasscode {
}
private int getMaxAccountCount() {
return hasNotHiddenPremium()
return hasAnyPremiumAccountThatWillNotBeHidden()
? UserConfig.FAKE_PASSCODE_MAX_PREMIUM_ACCOUNT_COUNT
: UserConfig.FAKE_PASSCODE_MAX_ACCOUNT_COUNT;
}
private boolean hasNotHiddenPremium() {
private boolean hasAnyPremiumAccountThatWillNotBeHidden() {
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
UserConfig userConfig = UserConfig.getInstance(a);
if (userConfig.isPremium() && (getAccountActions(a) == null || !getAccountActions(a).isLogOutOrHideAccount())) {

View file

@ -3,18 +3,15 @@ package org.telegram.messenger.fakepasscode;
import static org.telegram.messenger.MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS;
import static org.telegram.messenger.MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED;
import static org.telegram.messenger.MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_READ;
import static org.telegram.messenger.MessagesController.showCantOpenAlert;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.android.exoplayer2.util.Log;
import org.telegram.messenger.AccountInstance;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.BuildConfig;
import org.telegram.messenger.ChatObject;
import org.telegram.messenger.DialogObject;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.MessagesStorage;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.Utilities;
@ -214,7 +211,7 @@ public class RemoveChatsAction extends AccountAction implements NotificationCent
}
unpinHiddenDialogs();
SharedConfig.saveConfig();
getMessagesStorage().removeChatsActionExecuted();
getMessagesStorage().unreadCounterChangedByFakePasscode();
postNotifications(foldersCleared);
LongSparseIntArray dialogsToUpdate = new LongSparseIntArray(hiddenChatEntries.size());
hiddenChatEntries.stream().forEach(entry -> dialogsToUpdate.put(entry.chatId, 0));

View file

@ -2,5 +2,5 @@ package org.telegram.messenger.partisan;
public class PartisanVersion {
public static final String PARTISAN_VERSION_STRING = "4.2.0";
public static int PARTISAN_BUILD_VERSION = 1619;
public static int PARTISAN_BUILD_VERSION = 1622;
}

View file

@ -3,7 +3,6 @@ package org.telegram.messenger.partisan.secretgroups;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.SendMessagesHelper;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.partisan.AccountControllersProvider;
import org.telegram.tgnet.TLRPC;
@ -83,7 +82,7 @@ public class EncryptedGroupChatUpdateHandler implements AccountControllersProvid
getEncryptedGroupProtocol().sendSecondaryInnerChatInvitation(encryptedChat, encryptedGroup.getExternalId());
innerChat.setState(InnerEncryptedChatState.INITIALIZED);
getMessagesStorage().updateEncryptedGroupInnerChat(encryptedGroup.getInternalId(), innerChat);
getEncryptedGroupUtils().checkAllEncryptedChatsCreated(encryptedGroup);
getEncryptedGroupUtils().finalizeEncryptedGroupIfAllChatsCreated(encryptedGroup);
}
private void handleEncryptedChatDiscarded(EncryptedGroup encryptedGroup, TLRPC.EncryptedChat encryptedChat) {

View file

@ -2,4 +2,5 @@ package org.telegram.messenger.partisan.secretgroups;
public class EncryptedGroupConstants {
public static final int MAX_MEMBER_COUNT = 10;
public static final int FAST_GROUP_CREATION_MEMBER_COUNT = 6;
}

View file

@ -53,7 +53,7 @@ public class EncryptedGroupInnerChatStarter implements AccountControllersProvide
if (floodWaitUntil > 0 && floodWaitUntil > SystemClock.elapsedRealtime()) {
return;
}
Pair<InnerEncryptedChat, EncryptedGroup> pair = getNextUninitializedInnerChat();
Pair<InnerEncryptedChat, EncryptedGroup> pair = findNextInnerChatToInitialize();
if (pair != null) {
InnerEncryptedChat uninitializedInnerChat = pair.first;
EncryptedGroup encryptedGroup = pair.second;
@ -69,7 +69,7 @@ public class EncryptedGroupInnerChatStarter implements AccountControllersProvide
}
}
private Pair<InnerEncryptedChat, EncryptedGroup> getNextUninitializedInnerChat() {
private Pair<InnerEncryptedChat, EncryptedGroup> findNextInnerChatToInitialize() {
Pair<InnerEncryptedChat, EncryptedGroup> uninitializedInnerChat = getNextSecondaryChat();
if (uninitializedInnerChat == null) {
uninitializedInnerChat = getNextPrimaryChat();
@ -129,21 +129,23 @@ public class EncryptedGroupInnerChatStarter implements AccountControllersProvide
@Override
public void onComplete(TLRPC.EncryptedChat encryptedChat) {
if (encryptedChat != null) {
InnerEncryptedChat innerChat = encryptedGroup.getInnerChatByUserId(encryptedChat.user_id);
innerChat.setEncryptedChatId(encryptedChat.id);
if (encryptedGroup.isInState(CREATING_ENCRYPTED_CHATS)) {
onPrimaryChatStarted(innerChat);
} else if (encryptedGroup.isInState(WAITING_SECONDARY_CHAT_CREATION, NEW_MEMBER_WAITING_SECONDARY_CHAT_CREATION)) {
onSecondaryChatStarted(innerChat);
} else {
onMemberAdded(innerChat);
}
if (encryptedChat == null) {
currentDelegate = null;
return;
}
InnerEncryptedChat innerChat = encryptedGroup.getInnerChatByUserId(encryptedChat.user_id);
innerChat.setEncryptedChatId(encryptedChat.id);
if (encryptedGroup.isInState(CREATING_ENCRYPTED_CHATS)) {
handlePrimaryChatStarted(innerChat);
} else if (encryptedGroup.isInState(WAITING_SECONDARY_CHAT_CREATION, NEW_MEMBER_WAITING_SECONDARY_CHAT_CREATION)) {
handleSecondaryChatStarted(innerChat);
} else {
handleNewMemberChatStarted(innerChat);
}
currentDelegate = null;
}
private void onPrimaryChatStarted(InnerEncryptedChat innerChat) {
private void handlePrimaryChatStarted(InnerEncryptedChat innerChat) {
log(encryptedGroup, "A primary inner chat with a user started.");
innerChat.setState(InnerEncryptedChatState.NEED_SEND_INVITATION);
getMessagesStorage().updateEncryptedGroupInnerChat(encryptedGroup.getInternalId(), innerChat);
@ -157,15 +159,15 @@ public class EncryptedGroupInnerChatStarter implements AccountControllersProvide
}
}
private void onSecondaryChatStarted(InnerEncryptedChat innerChat) {
private void handleSecondaryChatStarted(InnerEncryptedChat innerChat) {
log(encryptedGroup, "A secondary inner chat with a user started.");
innerChat.setState(InnerEncryptedChatState.NEED_SEND_SECONDARY_INVITATION);
getMessagesStorage().updateEncryptedGroupInnerChat(encryptedGroup.getInternalId(), innerChat);
getEncryptedGroupUtils().checkAllEncryptedChatsCreated(encryptedGroup);
getEncryptedGroupUtils().finalizeEncryptedGroupIfAllChatsCreated(encryptedGroup);
}
private void onMemberAdded(InnerEncryptedChat innerChat) {
private void handleNewMemberChatStarted(InnerEncryptedChat innerChat) {
log(encryptedGroup, "A member added.");
innerChat.setState(InnerEncryptedChatState.NEW_MEMBER_NEED_SEND_INVITATION);
getMessagesStorage().updateEncryptedGroupInnerChat(encryptedGroup.getInternalId(), innerChat);

View file

@ -95,27 +95,35 @@ public class EncryptedGroupProtocol implements AccountControllersProvider {
action.userId = userId;
sendActionToAllMembers(encryptedGroup, action, true);
if (innerChat.isNotInState(InnerEncryptedChatState.CANCELLED)) {
NotificationCenter.NotificationCenterDelegate observer = new NotificationCenter.NotificationCenterDelegate() {
@Override
public void didReceivedNotification(int id, int account, Object... args) {
long dialogId = (long)args[3];
InnerEncryptedChat innerChat = encryptedGroup.getInnerChatByUserId(userId);
if (dialogId == innerChat.getDialogId().orElse(0L)) {
getNotificationCenter().removeObserver(this, NotificationCenter.messageReceivedByServer);
removeMember(encryptedGroup, userId);
if (encryptedGroup.allInnerChatsMatchState(InnerEncryptedChatState.WAITING_SECONDARY_CHATS_CREATION)) {
requestMembersToCreateSecondaryChats(encryptedGroup);
}
}
}
};
getNotificationCenter().addObserver(observer, NotificationCenter.messageReceivedByServer);
boolean needWaitForMessageReceiving = innerChat.isNotInState(InnerEncryptedChatState.CANCELLED)
&& innerChat.getDialogId().isPresent();
if (needWaitForMessageReceiving) {
waitForMessageReceivingByServer(innerChat.getDialogId().orElse(0L), () ->
finishKickingMember(encryptedGroup, userId)
);
} else {
removeMember(encryptedGroup, userId);
if (encryptedGroup.allInnerChatsMatchState(InnerEncryptedChatState.WAITING_SECONDARY_CHATS_CREATION)) {
requestMembersToCreateSecondaryChats(encryptedGroup);
finishKickingMember(encryptedGroup, userId);
}
}
private void waitForMessageReceivingByServer(long targetDialogId, Runnable action) {
NotificationCenter.NotificationCenterDelegate observer = new NotificationCenter.NotificationCenterDelegate() {
@Override
public void didReceivedNotification(int id, int account, Object... args) {
long currentDialogId = (long)args[3];
if (currentDialogId == targetDialogId) {
getNotificationCenter().removeObserver(this, NotificationCenter.messageReceivedByServer);
action.run();
}
}
};
getNotificationCenter().addObserver(observer, NotificationCenter.messageReceivedByServer);
}
private void finishKickingMember(EncryptedGroup encryptedGroup, long userId) {
removeMember(encryptedGroup, userId);
if (encryptedGroup.allInnerChatsMatchState(InnerEncryptedChatState.WAITING_SECONDARY_CHATS_CREATION)) {
requestMembersToCreateSecondaryChats(encryptedGroup);
}
}

View file

@ -7,6 +7,7 @@ import static org.telegram.messenger.partisan.secretgroups.EncryptedGroupState.W
import static org.telegram.messenger.partisan.secretgroups.EncryptedGroupState.WAITING_CONFIRMATION_FROM_OWNER;
import static org.telegram.messenger.partisan.secretgroups.EncryptedGroupState.WAITING_SECONDARY_CHAT_CREATION;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@ -14,6 +15,7 @@ import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.DialogObject;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.NotificationsController;
import org.telegram.messenger.Utilities;
import org.telegram.messenger.fakepasscode.FakePasscodeUtils;
import org.telegram.messenger.partisan.AccountControllersProvider;
@ -36,10 +38,10 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
@ -127,19 +129,11 @@ public class EncryptedGroupServiceMessagesHandler implements AccountControllersP
}
private Long extractExternalGroupIdFromAction() {
Field[] fields = serviceMessage.encryptedGroupAction.getClass().getDeclaredFields();
for (Field field : fields) {
ExternalGroupIdProvider annotation = field.getAnnotation(ExternalGroupIdProvider.class);
if (annotation != null) {
try {
return (Long)field.get(serviceMessage.encryptedGroupAction);
} catch (IllegalAccessException e) {
PartisanLog.e(e);
throw new RuntimeException(e);
}
}
if (serviceMessage.encryptedGroupAction instanceof ExternalGroupIdProvider) {
return ((ExternalGroupIdProvider)serviceMessage.encryptedGroupAction).getExternalGroupId();
} else {
return null;
}
return null;
}
private boolean validateHandlerConditions(HandlerCondition[] conditions) {
@ -326,6 +320,7 @@ public class EncryptedGroupServiceMessagesHandler implements AccountControllersP
getEncryptedGroupProtocol().sendNewAvatar(encryptedGroup, encryptedChat);
}
syncNewInnerChatTtl();
syncNewInnerChatNotificationSettings();
AndroidUtilities.runOnUIThread(() -> {
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload);
getNotificationCenter().postNotificationName(NotificationCenter.encryptedGroupUpdated, encryptedGroup);
@ -348,11 +343,47 @@ public class EncryptedGroupServiceMessagesHandler implements AccountControllersP
);
}
private void syncNewInnerChatNotificationSettings() {
Long otherDialogId = encryptedGroup.getInnerEncryptedChatIds(false).stream()
.filter(id -> id != encryptedChat.id)
.map(DialogObject::makeEncryptedDialogId)
.findFirst()
.orElse(null);
if (otherDialogId == null) {
return;
}
syncNotificationSetting("notify2_", otherDialogId);
syncNotificationSetting("notifyuntil_", otherDialogId);
syncNotificationSetting("sound_enabled_", otherDialogId);
}
private <T> void syncNotificationSetting(String settingsTypeKey, long sourceDialogId) {
String sourceKey = makeNotificationSettingsKey(settingsTypeKey, sourceDialogId);
String destinationKey = makeNotificationSettingsKey(settingsTypeKey, DialogObject.makeEncryptedDialogId(encryptedChat.id));
SharedPreferences preferences = MessagesController.getNotificationsSettings(accountNum);
if (!preferences.contains(sourceKey)) {
return;
}
Map<String, ?> allValues = preferences.getAll();
Object value = allValues.get(sourceKey);
SharedPreferences.Editor editor = preferences.edit();
if (value instanceof Integer) {
editor.putInt(destinationKey, (int)value);
} else if (value instanceof Boolean) {
editor.putBoolean(destinationKey, (boolean)value);
}
editor.apply();
}
private static String makeNotificationSettingsKey(String settingsTypeKey, long dialogId) {
return settingsTypeKey + NotificationsController.getSharedPrefKey(dialogId, 0);
}
@Handler(conditions = {HandlerCondition.GROUP_EXISTS, HandlerCondition.ACTION_FROM_OWNER}, groupStates = WAITING_CONFIRMATION_FROM_OWNER)
private TLRPC.Message handleConfirmGroupInitialization(ConfirmGroupInitializationAction action) {
encryptedGroup.setState(WAITING_SECONDARY_CHAT_CREATION);
getMessagesStorage().updateEncryptedGroup(encryptedGroup);
getEncryptedGroupUtils().checkAllEncryptedChatsCreated(encryptedGroup);
getEncryptedGroupUtils().finalizeEncryptedGroupIfAllChatsCreated(encryptedGroup);
AndroidUtilities.runOnUIThread(() -> {
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload);
getNotificationCenter().postNotificationName(NotificationCenter.encryptedGroupUpdated, encryptedGroup);
@ -371,13 +402,14 @@ public class EncryptedGroupServiceMessagesHandler implements AccountControllersP
getMessagesStorage().updateEncryptedGroupInnerChat(encryptedGroup.getInternalId(), innerChat);
if (encryptedGroup.isNotInState(INITIALIZED)) {
getEncryptedGroupUtils().checkAllEncryptedChatsCreated(encryptedGroup);
getEncryptedGroupUtils().finalizeEncryptedGroupIfAllChatsCreated(encryptedGroup);
}
AndroidUtilities.runOnUIThread(() -> {
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload);
getNotificationCenter().postNotificationName(NotificationCenter.encryptedGroupUpdated, encryptedGroup);
});
syncNewInnerChatTtl();
syncNewInnerChatNotificationSettings();
return null;
}
@ -397,7 +429,7 @@ public class EncryptedGroupServiceMessagesHandler implements AccountControllersP
private TLRPC.Message handleAllSecondaryChatsInitialized(AllSecondaryChatsInitializedAction action) {
innerChat.setState(InnerEncryptedChatState.INITIALIZED);
getMessagesStorage().updateEncryptedGroupInnerChat(encryptedGroup.getInternalId(), innerChat);
getEncryptedGroupUtils().checkAllEncryptedChatsCreated(encryptedGroup);
getEncryptedGroupUtils().finalizeEncryptedGroupIfAllChatsCreated(encryptedGroup);
AndroidUtilities.runOnUIThread(() -> {
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload);
getNotificationCenter().postNotificationName(NotificationCenter.encryptedGroupUpdated, encryptedGroup);
@ -453,7 +485,7 @@ public class EncryptedGroupServiceMessagesHandler implements AccountControllersP
} else {
getEncryptedGroupProtocol().removeMember(encryptedGroup, action.userId);
if (encryptedGroup.isInState(WAITING_SECONDARY_CHAT_CREATION)) {
getEncryptedGroupUtils().checkAllEncryptedChatsCreated(encryptedGroup);
getEncryptedGroupUtils().finalizeEncryptedGroupIfAllChatsCreated(encryptedGroup);
}
}
return createMessageForStoring();

View file

@ -29,6 +29,7 @@ import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -46,10 +47,9 @@ public class EncryptedGroupUtils implements AccountControllersProvider {
this.accountNum = accountNum;
}
public void checkAllEncryptedChatsCreated(EncryptedGroup encryptedGroup) {
EncryptedGroupState groupState = encryptedGroup.getState();
if (groupState != EncryptedGroupState.WAITING_SECONDARY_CHAT_CREATION && groupState != EncryptedGroupState.NEW_MEMBER_WAITING_SECONDARY_CHAT_CREATION) {
throw new RuntimeException("Invalid encrypted group state: " + groupState);
public void finalizeEncryptedGroupIfAllChatsCreated(EncryptedGroup encryptedGroup) {
if (encryptedGroup.isNotInState(EncryptedGroupState.WAITING_SECONDARY_CHAT_CREATION, EncryptedGroupState.NEW_MEMBER_WAITING_SECONDARY_CHAT_CREATION)) {
throw new RuntimeException("Invalid encrypted group state: " + encryptedGroup.getState());
}
if (encryptedGroup.allInnerChatsMatchState(InnerEncryptedChatState.INITIALIZED)) {
log(encryptedGroup, "All encrypted chats initialized.");
@ -61,11 +61,10 @@ public class EncryptedGroupUtils implements AccountControllersProvider {
getEncryptedGroupProtocol().sendAllSecondaryChatsInitialized(ownerEncryptedChat);
}
} else if (PartisanLog.logsAllowed()) {
String notInitializedInnerChats = encryptedGroup.getInnerChats().stream()
long notInitializedInnerChatCount = encryptedGroup.getInnerChats().stream()
.filter(innerChat -> innerChat.getState() != InnerEncryptedChatState.INITIALIZED)
.map(innerChat -> Long.toString(innerChat.getUserId()))
.collect(Collectors.joining(", "));
log(encryptedGroup, "NOT all encrypted chats initialized: " + notInitializedInnerChats.length() + ".");
.count();
log(encryptedGroup, "NOT all encrypted chats initialized: " + notInitializedInnerChatCount + ".");
}
}
@ -100,7 +99,7 @@ public class EncryptedGroupUtils implements AccountControllersProvider {
}
}
public boolean doForEachInnerDialogIdIfNeeded(long encryptedGroupDialogId, Consumer<Long> action) {
public boolean forEachInnerDialogIdIfEncryptedGroup(long encryptedGroupDialogId, Consumer<Long> action) {
if (!DialogObject.isEncryptedDialog(encryptedGroupDialogId)) {
return false;
}
@ -225,9 +224,9 @@ public class EncryptedGroupUtils implements AccountControllersProvider {
}
private void confirmJoining(EncryptedGroup encryptedGroup) {
forceHidePreview(encryptedGroup);
deleteInvitationMessageForNonPtgUsers(encryptedGroup);
for (int i = 1; i <= 20; i++) {
AndroidUtilities.runOnUIThread(() -> forceHidePreview(encryptedGroup), 100 * i);
AndroidUtilities.runOnUIThread(() -> deleteInvitationMessageForNonPtgUsers(encryptedGroup), 100 * i);
}
if (encryptedGroup.isInState(EncryptedGroupState.JOINING_NOT_CONFIRMED)) {
@ -242,7 +241,7 @@ public class EncryptedGroupUtils implements AccountControllersProvider {
getEncryptedGroupProtocol().sendJoinConfirmation(encryptedChat);
}
public void forceHidePreview(EncryptedGroup encryptedGroup) {
public void deleteInvitationMessageForNonPtgUsers(EncryptedGroup encryptedGroup) {
if (encryptedGroup.isNotInState(EncryptedGroupState.INITIALIZED)) {
Integer ownerEncryptedChatId = encryptedGroup.getInnerChatByUserId(encryptedGroup.getOwnerUserId()).getEncryptedChatId().orElse(null);
long chatDialogId = DialogObject.makeEncryptedDialogId(ownerEncryptedChatId);
@ -336,7 +335,7 @@ public class EncryptedGroupUtils implements AccountControllersProvider {
public EncryptedGroup getOrLoadEncryptedGroupByDialogId(long dialogId) {
EncryptedGroup encryptedGroup = null;
if (DialogObject.isEncryptedDialog(dialogId)) {
encryptedGroup = getEncryptedGroupUtils().getOrLoadEncryptedGroup(DialogObject.getEncryptedChatId(dialogId));
encryptedGroup = getOrLoadEncryptedGroup(DialogObject.getEncryptedChatId(dialogId));
}
return encryptedGroup;
}
@ -359,7 +358,7 @@ public class EncryptedGroupUtils implements AccountControllersProvider {
return getMessagesStorage().getEncryptedGroupIdByInnerEncryptedChatId(encryptedChatId) != null;
}
public boolean putEncIdOrEncGroupIdInBundle(Bundle bundle, long dialogId) {
public boolean putEncIdOrEncGroupIdInBundleIfPossible(Bundle bundle, long dialogId) {
EncryptedGroup encryptedGroup = getMessagesController().getEncryptedGroup(DialogObject.getEncryptedChatId(dialogId));
if (encryptedGroup != null) {
if (encryptedGroup.isInState(EncryptedGroupState.JOINING_NOT_CONFIRMED, EncryptedGroupState.NEW_MEMBER_JOINING_NOT_CONFIRMED)) {
@ -423,9 +422,13 @@ public class EncryptedGroupUtils implements AccountControllersProvider {
}
public static byte[] serializeAvatar(EncryptedGroup encryptedGroup) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
encryptedGroup.getAvatar().compress(android.graphics.Bitmap.CompressFormat.JPEG, 80, stream);
return stream.toByteArray();
try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
encryptedGroup.getAvatar().compress(android.graphics.Bitmap.CompressFormat.JPEG, 80, stream);
return stream.toByteArray();
} catch (IOException e) {
PartisanLog.e("Error serializing encrypted group avatar", e);
return new byte[0];
}
}
public static Bitmap deserializeAvatarFromByteBuffer(NativeByteBuffer buffer) {
@ -437,7 +440,7 @@ public class EncryptedGroupUtils implements AccountControllersProvider {
}
}
public void syncTtlIfNeeded(TLRPC.EncryptedChat encryptedChat) {
public void syncTtlWithOtherMembersIfNeeded(TLRPC.EncryptedChat encryptedChat) {
EncryptedGroup encryptedGroup = getOrLoadEncryptedGroupByEncryptedChat(encryptedChat);
if (encryptedGroup == null) {
return;

View file

@ -6,8 +6,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public abstract class AbstractCreateGroupAction extends EncryptedGroupAction {
@ExternalGroupIdProvider()
public abstract class AbstractCreateGroupAction extends EncryptedGroupAction implements ExternalGroupIdProvider {
public long externalGroupId;
public String name;
public List<Long> memberIds = new ArrayList<>();
@ -26,4 +25,9 @@ public abstract class AbstractCreateGroupAction extends EncryptedGroupAction {
public int hashCode() {
return Objects.hash(externalGroupId, name, memberIds, ownerUserId);
}
@Override
public long getExternalGroupId() {
return externalGroupId;
}
}

View file

@ -5,7 +5,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface ExternalGroupIdProvider {
public interface ExternalGroupIdProvider {
long getExternalGroupId();
}

View file

@ -3,10 +3,9 @@ package org.telegram.messenger.partisan.secretgroups.action;
import org.telegram.tgnet.InputSerializedData;
import org.telegram.tgnet.OutputSerializedData;
public class StartSecondaryInnerChatAction extends EncryptedGroupAction {
public class StartSecondaryInnerChatAction extends EncryptedGroupAction implements ExternalGroupIdProvider {
public static final int constructor = 0x19fbd964;
@ExternalGroupIdProvider()
public long externalGroupId;
@Override
@ -20,4 +19,9 @@ public class StartSecondaryInnerChatAction extends EncryptedGroupAction {
stream.writeInt64(externalGroupId);
}
@Override
public long getExternalGroupId() {
return externalGroupId;
}
}

View file

@ -1,5 +1,7 @@
package org.telegram.messenger.partisan.secretgroups.ui;
import static org.telegram.messenger.LocaleController.getString;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
@ -446,9 +448,9 @@ public class EncryptedGroupCreateActivity extends BaseFragment implements Notifi
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
if (isAddToGroup()) {
actionBar.setTitle(LocaleController.getString(R.string.GroupAddMembers));
actionBar.setTitle(getString(R.string.GroupAddMembers));
} else {
actionBar.setTitle(LocaleController.getString(R.string.NewEncryptedGroup));
actionBar.setTitle(getString(R.string.NewEncryptedGroup));
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@ -680,7 +682,7 @@ public class EncryptedGroupCreateActivity extends BaseFragment implements Notifi
emptyView = new StickerEmptyView(context, flickerLoadingView, StickerEmptyView.STICKER_TYPE_SEARCH);
emptyView.addView(flickerLoadingView);
emptyView.showProgress(true, false);
emptyView.title.setText(LocaleController.getString(R.string.NoResult));
emptyView.title.setText(getString(R.string.NoResult));
frameLayout.addView(emptyView);
@ -699,53 +701,37 @@ public class EncryptedGroupCreateActivity extends BaseFragment implements Notifi
if (view instanceof GroupCreateUserCell) {
GroupCreateUserCell cell = (GroupCreateUserCell) view;
Object object = cell.getObject();
long id;
if (object instanceof TLRPC.User) {
id = ((TLRPC.User) object).id;
} else if (object instanceof TLRPC.Chat) {
id = -((TLRPC.Chat) object).id;
} else {
if (!(object instanceof TLRPC.User)) {
return;
}
if (encryptedGroup != null && encryptedGroup.getInnerChatByUserId(id) != null) {
TLRPC.User user = (TLRPC.User) object;
long did = user.id;
if (encryptedGroup != null && encryptedGroup.getInnerChatByUserId(did) != null) {
return;
}
if (selectedContacts.indexOfKey(id) >= 0) {
GroupCreateSpan span = selectedContacts.get(id);
if (selectedContacts.indexOfKey(did) >= 0) {
GroupCreateSpan span = selectedContacts.get(did);
spansContainer.removeSpan(span);
} else {
if (maxCount != 0 && getFullMembersCount() == maxCount || isAddToGroup() && !selectedContacts.isEmpty()) { // allow adding only 1 new member
if (getFullMembersCount() == maxCount) {
showLimitReachedDialog();
return;
}
if (selectedContacts.size() == getMessagesController().maxGroupCount) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString(R.string.AppName));
builder.setMessage(LocaleController.getString(R.string.SoftUserLimitAlert));
builder.setPositiveButton(LocaleController.getString(R.string.OK), null);
showDialog(builder.create());
return;
}
long did = 0;
if (object instanceof TLRPC.User) {
TLRPC.User user = (TLRPC.User) object;
getMessagesController().putUser(user, !searching);
did = user.id;
} else if (object instanceof TLRPC.Chat) {
TLRPC.Chat chat = (TLRPC.Chat) object;
getMessagesController().putChat(chat, !searching);
did = chat.id;
}
getMessagesController().putUser(user, !searching);
if (isAddToGroup()) {
long finalDid = did;
AlertsCreator.showConfirmationDialog(this, context, LocaleController.getString(R.string.VoipGroupAddMemberTitle), () -> {
selectedContacts.put(finalDid, null);
AlertsCreator.showConfirmationDialog(this, context, getString(R.string.VoipGroupAddMemberTitle), () -> {
selectedContacts.put(did, null);
onDonePressed();
});
return;
} else {
GroupCreateSpan span = new GroupCreateSpan(editText.getContext(), object, currentAccount);
spansContainer.addSpan(span);
span.setOnClickListener(EncryptedGroupCreateActivity.this);
if (getFullMembersCount() == EncryptedGroupConstants.FAST_GROUP_CREATION_MEMBER_COUNT) {
showSlowGroupCreationWarning();
}
}
GroupCreateSpan span = new GroupCreateSpan(editText.getContext(), object, currentAccount);
spansContainer.addSpan(span);
span.setOnClickListener(EncryptedGroupCreateActivity.this);
}
selectedCountUpdated();
if (searching || searchWas) {
@ -810,20 +796,32 @@ public class EncryptedGroupCreateActivity extends BaseFragment implements Notifi
floatingButton.setScaleY(0.0f);
floatingButton.setAlpha(0.0f);
}
floatingButton.setContentDescription(LocaleController.getString(R.string.Next));
floatingButton.setContentDescription(getString(R.string.Next));
selectedCountUpdated();
return fragmentView;
}
private void showSlowGroupCreationWarning() {
AlertsCreator.showSimpleAlert(this, getString(R.string.Warning), getString(R.string.SlowSecretGroupCreationWarning));
}
private void showLimitReachedDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(getString(R.string.AppName));
builder.setMessage(getString(R.string.LimitReached));
builder.setPositiveButton(getString(R.string.OK), null);
showDialog(builder.create());
}
private void updateEditTextHint() {
if (editText == null) {
return;
}
if (isAddToGroup() || (adapter != null && adapter.noContactsStubRow == 0)) {
editText.setHintText(LocaleController.getString(R.string.SearchForPeople));
editText.setHintText(getString(R.string.SearchForPeople));
} else {
editText.setHintText(LocaleController.getString(R.string.SendMessageTo));
editText.setHintText(getString(R.string.SendMessageTo));
}
}
@ -930,7 +928,7 @@ public class EncryptedGroupCreateActivity extends BaseFragment implements Notifi
int position = listView.getChildAdapterPosition(child);
if (position == adapter.firstSectionRow) {
GraySectionCell cell = (GraySectionCell) child;
cell.setRightText(!selectedContacts.isEmpty() ? LocaleController.getString(R.string.DeselectAll) : "", true, v -> {
cell.setRightText(!selectedContacts.isEmpty() ? getString(R.string.DeselectAll) : "", true, v -> {
selectedContacts.clear();
spansContainer.removeAllSpans(true);
checkVisibleRows();
@ -955,8 +953,8 @@ public class EncryptedGroupCreateActivity extends BaseFragment implements Notifi
if (encryptedGroup == null) {
DialogTemplate template = new DialogTemplate();
template.type = DialogType.CREATE;
template.title = LocaleController.getString(R.string.GroupName);
template.addEditTemplate("", LocaleController.getString(R.string.EnterGroupNamePlaceholder), true);
template.title = getString(R.string.GroupName);
template.addEditTemplate("", getString(R.string.EnterGroupNamePlaceholder), true);
template.positiveListener = views -> {
String chatName = ((EditTextCaption)views.get(0)).getText().toString();
@ -1198,7 +1196,7 @@ public class EncryptedGroupCreateActivity extends BaseFragment implements Notifi
};
stickerEmptyView.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
stickerEmptyView.subtitle.setVisibility(View.GONE);
stickerEmptyView.title.setText(LocaleController.getString(R.string.NoContacts));
stickerEmptyView.title.setText(getString(R.string.NoContacts));
stickerEmptyView.setAnimateLayoutChange(true);
view = stickerEmptyView;
break;
@ -1212,12 +1210,12 @@ public class EncryptedGroupCreateActivity extends BaseFragment implements Notifi
case 0: {
GraySectionCell cell = (GraySectionCell) holder.itemView;
if (searching) {
cell.setText(LocaleController.getString(R.string.GlobalSearch));
cell.setText(getString(R.string.GlobalSearch));
} else if (position == userTypesHeaderRow) {
cell.setText(LocaleController.getString(R.string.PrivacyUserTypes));
cell.setText(getString(R.string.PrivacyUserTypes));
}
if (position == firstSectionRow) {
cell.setRightText(!selectedContacts.isEmpty() ? LocaleController.getString(R.string.DeselectAll) : "", true, v -> {
cell.setRightText(!selectedContacts.isEmpty() ? getString(R.string.DeselectAll) : "", true, v -> {
selectedContacts.clear();
spansContainer.removeAllSpans(true);
checkVisibleRows();

View file

@ -165,6 +165,9 @@ public class EncryptedGroupProfileActivity extends BaseFragment implements Notif
if (SharedConfig.detailedEncryptedGroupMemberStatus) {
statusRow = rowCount++;
idRow = rowCount++;
} else {
statusRow = -1;
idRow = -1;
}
firstMemberRow = rowCount;
lastMemberRow = firstMemberRow + encryptedGroup.getInnerChats().size();

View file

@ -4292,9 +4292,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
@Override
public void toggleSound() {
boolean wasEnabled = isEncryptedGroup()
? currentEncryptedGroup.getInnerEncryptedChatDialogIds().stream()
.anyMatch(innerDialogId -> getMessagesController().isDialogNotificationsSoundEnabled(innerDialogId, getTopicId()))
: false;
forEachDialogId(dialog_id -> {
SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
boolean enabled = !preferences.getBoolean("sound_enabled_" + NotificationsController.getSharedPrefKey(dialog_id, getTopicId()), true);
if (isEncryptedGroup()) {
enabled = !wasEnabled;
}
preferences.edit().putBoolean("sound_enabled_" + NotificationsController.getSharedPrefKey(dialog_id, getTopicId()), enabled).apply();
if (BulletinFactory.canShowBulletin(ChatActivity.this)) {
BulletinFactory.createSoundEnabledBulletin(ChatActivity.this, enabled ? NotificationsController.SETTING_SOUND_ON : NotificationsController.SETTING_SOUND_OFF, getResourceProvider()).show();
@ -12885,7 +12892,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
final boolean updateStickersOrderFinal = updateStickersOrder;
if (autoDeleteDelay != null) {
SendMessagesHelper.prepareSendingMedia(getAccountInstance(), photos, dialog_id, replyingMessageObject, getThreadMessage(), null, replyingQuote, button == 4 || forceDocument, arg, editingMessageObject, notify, scheduleDate, chatMode, updateStickersOrderFinal, null, quickReplyShortcut, getQuickReplyId(), effectId, invertMedia, payStars, autoDeleteDelay);
SendMessagesHelper.prepareSendingMedia(getAccountInstance(), photos, dialog_id, replyingMessageObject, getThreadMessage(), null, replyingQuote, button == 4 || forceDocument, arg, editingMessageObject, notify, scheduleDate, chatMode, updateStickersOrderFinal, null, quickReplyShortcut, getQuickReplyId(), effectId, invertMedia, payStars, getSendMonoForumPeerId(), autoDeleteDelay);
} else {
SendMessagesHelper.prepareSendingMedia(getAccountInstance(), photos, dialog_id, replyingMessageObject, getThreadMessage(), null, replyingQuote, button == 4 || forceDocument, arg, editingMessageObject, notify, scheduleDate, chatMode, updateStickersOrderFinal, null, quickReplyShortcut, getQuickReplyId(), effectId, invertMedia, payStars, getSendMonoForumPeerId());
}
@ -14068,10 +14075,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
waitingForLoad.add(lastLoadIndex);
getMessagesController().loadMessages(mergeDialogId, 0, false, 50, getMinMessageId(dialog_id, 1), 0, true, getMaxDate(dialog_id, 1), classGuid, 1, 0, chatMode, threadMessageId, replyMaxReadId, lastLoadIndex++, isTopic);
loadingForward = true;
} else if (!getForwardEndReached(dialog_id, 0)) {
waitingForLoad.add(lastLoadIndex);
getMessagesController().loadMessages(dialog_id, mergeDialogId, false, 50, getMinMessageId(dialog_id, 0), 0, true, getMaxDate(dialog_id, 0), classGuid, 1, 0, chatMode, threadMessageId, replyMaxReadId, lastLoadIndex++, isTopic);
loadingForward = true;
} else if (!forwardEndReachedForAll(0)) {
forEachDialogId(dialog_id -> {
waitingForLoad.add(lastLoadIndex);
getMessagesController().loadMessages(dialog_id, mergeDialogId, false, 50, getMinMessageId(dialog_id, 0), 0, true, getMaxDate(dialog_id, 0), classGuid, 1, 0, chatMode, threadMessageId, replyMaxReadId, lastLoadIndex++, isTopic);
loadingForward = true;
});
}
}
});
@ -21113,9 +21122,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
previous = null;
for (int i = messages.size() - 1; i >= 0; i--) {
MessageObject otherMessage = messages.get(i);
if (otherMessage.getDialogId() == obj.getDialogId() && otherMessage.type != MessageObject.TYPE_DATE) {
previous = otherMessage;
break;
for (MessageObject otherMessageCopy : getMessageCopies(otherMessage)) {
if (otherMessageCopy.getDialogId() == obj.getDialogId() && otherMessageCopy.type != MessageObject.TYPE_DATE) {
previous = otherMessageCopy;
break;
}
}
}
} else {
@ -24364,7 +24375,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (needAddMessage) {
messages.add(pos, obj);
messages.sort(Collections.reverseOrder(Comparator.comparingInt(m -> m.messageOwner.date)));
boolean added = !removeServiceMessagesDuplications();
boolean added = !removeServiceMessageDuplicationsIfAny();
if (obj.isOut()) {
hiddenEncryptedGroupOutMessages.put(obj.messageOwner.random_id, new ArrayList<>());
}
@ -24376,8 +24387,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
private boolean removeServiceMessagesDuplications() {
boolean modified = false;
private boolean removeServiceMessageDuplicationsIfAny() {
boolean duplicationsFound = false;
for (int i = messages.size() - 1; i >= 0; i--) {
if (i > 0) {
TLRPC.DecryptedMessageAction currentAction = getMessageAction(messages.get(i));
@ -24385,11 +24396,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (actionsEquals(currentAction, previousAction)) {
messages.remove(i);
modified = true;
duplicationsFound = true;
}
}
}
return modified;
return duplicationsFound;
}
private static TLRPC.DecryptedMessageAction getMessageAction(MessageObject message) {
@ -25619,7 +25630,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
obj.stableId = lastStableId++;
getMessagesController().getTranslateController().checkTranslation(obj, false);
if (!addMessage(placeToPaste, obj)) {
return;
continue;
}
if (placeToPaste == 0 && !obj.isSponsored()) {
needMoveScrollToLastMessage = true;
@ -30568,40 +30579,22 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
AlertsCreator.createDeleteMessagesAlert(this, currentUser, currentChat, currentEncryptedChatSingle, chatInfo, mergeDialogId, finalSelectedObject, selectedMessagesIds, finalSelectedGroup, (int) getTopicId(), chatMode, null, () -> {
hideActionMode();
updatePinnedMessageView(true);
}, hideDimAfter ? () -> dimBehindView(false) : null, themeDelegate, createEncryptedMessagesMapToDelete(finalSelectedObject));
},
hideDimAfter ? () -> dimBehindView(false) : null,
themeDelegate,
createEncryptedMessagesMapToDelete(finalSelectedObject),
createEncryptedMessagesGroupMapToDelete(finalSelectedGroup)
);
}
private Map<TLRPC.EncryptedChat, List<MessageObject>> createEncryptedMessagesMapToDelete(MessageObject finalSelectedObject) {
if (!isEncryptedGroup()) {
return null;
}
List<MessageObject> srcMessages;
if (finalSelectedObject != null) {
srcMessages = Collections.singletonList(finalSelectedObject);
} else {
srcMessages = new ArrayList<>();
for (int a = 1; a >= 0; a--) {
for (int b = 0; b < selectedMessagesIds[a].size(); b++) {
srcMessages.add(selectedMessagesIds[a].valueAt(b));
}
}
}
Map<TLRPC.EncryptedChat, List<MessageObject>> encryptedGroupMessages = new HashMap<>();
for (MessageObject message : srcMessages) {
List<MessageObject> messageCopies;
if (message.isOut()) {
long randomId = message.messageOwner.random_id;
messageCopies = new ArrayList<>(hiddenEncryptedGroupOutMessages.computeIfAbsent(randomId, k -> new ArrayList<>()));
messageCopies.add(message);
} else {
messageCopies = Collections.singletonList(message);
}
for (MessageObject messageCopy : messageCopies) {
long dialogId = messageCopy.getDialogId();
TLRPC.EncryptedChat encryptedChat = getCurrentEncryptedChatList(false).stream()
.filter(c -> DialogObject.makeEncryptedDialogId(c.id) == dialogId)
.findAny()
.orElse(null);
for (MessageObject message : getSrcMessages(finalSelectedObject)) {
for (MessageObject messageCopy : getMessageCopies(message)) {
TLRPC.EncryptedChat encryptedChat = getEncryptedChatByDialogId(messageCopy.getDialogId());
List<MessageObject> dialogMessages = encryptedGroupMessages.computeIfAbsent(encryptedChat, k -> new ArrayList<>());
dialogMessages.add(messageCopy);
}
@ -30609,6 +30602,54 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return encryptedGroupMessages;
}
private List<MessageObject> getSrcMessages(MessageObject finalSelectedObject) {
if (finalSelectedObject != null) {
return Collections.singletonList(finalSelectedObject);
} else {
List<MessageObject>srcMessages = new ArrayList<>();
for (int a = 1; a >= 0; a--) {
for (int b = 0; b < selectedMessagesIds[a].size(); b++) {
srcMessages.add(selectedMessagesIds[a].valueAt(b));
}
}
return srcMessages;
}
}
private List<MessageObject> getMessageCopies(MessageObject message) {
if (message.isOut()) {
long randomId = message.messageOwner.random_id;
List<MessageObject> messageCopies = new ArrayList<>(hiddenEncryptedGroupOutMessages.computeIfAbsent(randomId, k -> new ArrayList<>()));
messageCopies.add(message);
return messageCopies;
} else {
return Collections.singletonList(message);
}
}
private TLRPC.EncryptedChat getEncryptedChatByDialogId(long dialogId) {
if (!DialogObject.isEncryptedDialog(dialogId)) {
return null;
}
return getMessagesController().getEncryptedChat(DialogObject.getEncryptedChatId(dialogId));
}
private Map<TLRPC.EncryptedChat, MessageObject.GroupedMessages> createEncryptedMessagesGroupMapToDelete(MessageObject.GroupedMessages finalSelectedGroup) {
if (!isEncryptedGroup() || finalSelectedGroup == null || finalSelectedGroup.messages.isEmpty()) {
return null;
}
Map<TLRPC.EncryptedChat, MessageObject.GroupedMessages> encryptedGroupMessageGroups = new HashMap<>();
for (MessageObject message : getMessageCopies(finalSelectedGroup.messages.get(0))) {
MessageObject.GroupedMessages messageGroup = getValidGroupedMessage(message);
if (messageGroup != null) {
TLRPC.EncryptedChat encryptedChat = getEncryptedChatByDialogId(message.getDialogId());
encryptedGroupMessageGroups.put(encryptedChat, messageGroup);
}
}
return encryptedGroupMessageGroups;
}
private void forEachMessageCopy(MessageObject message, Consumer<MessageObject> action) {
if (isEncryptedGroup() && message.isOut()) {
if (hiddenEncryptedGroupOutMessages.containsKey(message.messageOwner.random_id)) {
@ -33548,18 +33589,22 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (group != null) {
boolean success = true;
for (int a = 0; a < group.messages.size(); a++) {
if (!getSendMessagesHelper().retrySendMessage(group.messages.get(a), false, payStars)) {
success = false;
for (MessageObject messageCopy : getMessageCopies(group.messages.get(a))) {
if (!getSendMessagesHelper().retrySendMessage(messageCopy, false, payStars)) {
success = false;
}
}
}
if (success && chatMode == 0) {
moveScrollToLastMessage(false);
}
} else {
if (getSendMessagesHelper().retrySendMessage(object, false, payStars)) {
updateVisibleRows();
if (chatMode == 0) {
moveScrollToLastMessage(false);
for (MessageObject messageCopy : getMessageCopies(object)) {
if (getSendMessagesHelper().retrySendMessage(messageCopy, false, payStars)) {
updateVisibleRows();
if (chatMode == 0) {
moveScrollToLastMessage(false);
}
}
}
}
@ -34452,7 +34497,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
Bundle args = new Bundle();
args.putBoolean("scrollToTopOnResume", scrollToTopOnResume);
if (DialogObject.isEncryptedDialog(did)) {
if (!getEncryptedGroupUtils().putEncIdOrEncGroupIdInBundle(args, did)) {
if (!getEncryptedGroupUtils().putEncIdOrEncGroupIdInBundleIfPossible(args, did)) {
return true;
}
} else {
@ -43793,6 +43838,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (!isEncryptedGroup()) {
return singleArray[index];
} else {
if (dialogId == DialogObject.makeEncryptedDialogId(currentEncryptedGroup.getInternalId())) {
T defaultValue = mappingFunction.apply(dialogId)[index];
return defaultValue;
}
initEncryptedGroupMapIfNeeded();
return encryptedGroupMap.computeIfAbsent(dialogId, mappingFunction)[index];
}

View file

@ -6525,7 +6525,7 @@ public class AlertsCreator {
void didPressedNewCard();
}
public static void createDeleteMessagesAlert(BaseFragment fragment, TLRPC.User user, TLRPC.Chat chat, TLRPC.EncryptedChat encryptedChat, TLRPC.ChatFull chatInfo, long mergeDialogId, MessageObject selectedMessage, SparseArray<MessageObject>[] selectedMessages, MessageObject.GroupedMessages selectedGroup, int topicId, int mode, TLRPC.ChannelParticipant[] channelParticipants, Runnable onDelete, Runnable hideDim, Theme.ResourcesProvider resourcesProvider, Map<TLRPC.EncryptedChat, List<MessageObject>> encryptedGroupMessages) {
public static void createDeleteMessagesAlert(BaseFragment fragment, TLRPC.User user, TLRPC.Chat chat, TLRPC.EncryptedChat encryptedChat, TLRPC.ChatFull chatInfo, long mergeDialogId, MessageObject selectedMessage, SparseArray<MessageObject>[] selectedMessages, MessageObject.GroupedMessages selectedGroup, int topicId, int mode, TLRPC.ChannelParticipant[] channelParticipants, Runnable onDelete, Runnable hideDim, Theme.ResourcesProvider resourcesProvider, Map<TLRPC.EncryptedChat, List<MessageObject>> encryptedGroupMessages, Map<TLRPC.EncryptedChat, MessageObject.GroupedMessages> encryptedGroupMessageGroups) {
final boolean scheduled = mode == ChatActivity.MODE_SCHEDULED;
final boolean isSavedMessages = mode == ChatActivity.MODE_SAVED;
final boolean quickReplies = mode == ChatActivity.MODE_QUICK_REPLIES;
@ -6676,7 +6676,7 @@ public class AlertsCreator {
}
progressDialog[0] = null;
createDeleteMessagesAlert(fragment, user, chat, encryptedChat, chatInfo, mergeDialogId, selectedMessage, selectedMessages, selectedGroup, topicId, mode, channelParticipantsLoad, onDelete, hideDim, resourcesProvider, encryptedGroupMessages);
createDeleteMessagesAlert(fragment, user, chat, encryptedChat, chatInfo, mergeDialogId, selectedMessage, selectedMessages, selectedGroup, topicId, mode, channelParticipantsLoad, onDelete, hideDim, resourcesProvider, encryptedGroupMessages, encryptedGroupMessageGroups);
}
}));
}
@ -6845,19 +6845,37 @@ public class AlertsCreator {
};
AlertDialog.OnButtonClickListener encryptedGroupDeleteAction = (dialogInterface, i) -> {
for (Map.Entry<TLRPC.EncryptedChat, List<MessageObject>> dialogEntry : encryptedGroupMessages.entrySet()) {
TLRPC.EncryptedChat currentEncryptedChat = dialogEntry.getKey();
List<MessageObject> messages = dialogEntry.getValue();
ArrayList<Integer> ids = messages.stream()
.map(MessageObject::getId)
.collect(toCollection(ArrayList::new));
ArrayList<Long> random_ids = messages.stream()
.filter(m -> m.messageOwner.random_id != 0 && m.type != 10)
.map(m -> m.messageOwner.random_id)
.collect(toCollection(ArrayList::new));
MessageObject.GroupedMessages messageGroup = encryptedGroupMessageGroups != null ? encryptedGroupMessageGroups.get(currentEncryptedChat) : null;
ArrayList<Integer> ids = new ArrayList<>();
ArrayList<Long> random_ids = null;
if (messageGroup != null) {
for (int a = 0; a < messageGroup.messages.size(); a++) {
MessageObject messageObject = messageGroup.messages.get(a);
ids.add(messageObject.getId());
if (messageObject.messageOwner.random_id != 0 && messageObject.type != 10) {
if (random_ids == null) {
random_ids = new ArrayList<>();
}
random_ids.add(messageObject.messageOwner.random_id);
}
}
} else {
messages.stream()
.map(MessageObject::getId)
.forEach(ids::add);
random_ids = messages.stream()
.filter(m -> m.messageOwner.random_id != 0 && m.type != 10)
.map(m -> m.messageOwner.random_id)
.collect(toCollection(ArrayList::new));
}
MessagesController.getInstance(currentAccount).deleteMessages(ids, random_ids, currentEncryptedChat,
DialogObject.makeEncryptedDialogId(currentEncryptedChat.id), topicId, deleteForAll[0], mode);
}
if (onDelete != null) {
onDelete.run();
}

View file

@ -150,7 +150,7 @@ public class AvatarDrawable extends Drawable {
}
public AvatarDrawable(TLRPC.User user, boolean profile, int accountNum) {
this(user, profile, UserConfig.getChatTitleOverride(accountNum, user.id));
this(user, profile, user != null ? UserConfig.getChatTitleOverride(accountNum, user.id) : null);
}
public AvatarDrawable(TLRPC.User user, boolean profile, String titleOverride) {
@ -177,7 +177,7 @@ public class AvatarDrawable extends Drawable {
}
public AvatarDrawable(TLRPC.Chat chat, boolean profile, int accountNum) {
this(chat, profile, UserConfig.getChatTitleOverride(accountNum, chat));
this(chat, profile, chat != null ? UserConfig.getChatTitleOverride(accountNum, chat) : null);
}
public AvatarDrawable(TLRPC.Chat chat, boolean profile, String titleOverride) {

View file

@ -5156,7 +5156,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
TLRPC.EncryptedChat encryptedChat = parentFragment != null ? parentFragment.getCurrentEncryptedChatSingle() : null;
messageEditText.setAllowTextEntitiesIntersection(supportsSendingNewEntities());
int flags = EditorInfo.IME_FLAG_NO_EXTRACT_UI;
if (isKeyboardSupportIncognitoMode() && encryptedChat != null) {
if (isKeyboardSupportIncognitoMode() && (encryptedChat != null || getParentFragment() != null && getParentFragment().isEncryptedGroup())) {
flags |= EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING;
}
messageEditText.setIncludeFontPadding(false);

View file

@ -92,7 +92,6 @@ import org.telegram.messenger.Utilities;
import org.telegram.messenger.browser.Browser;
import org.telegram.messenger.fakepasscode.FakePasscodeUtils;
import org.telegram.messenger.partisan.Utils;
import org.telegram.messenger.partisan.secretgroups.EncryptedGroupUtils;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
@ -4617,7 +4616,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
showActionMode(false);
actionBar.closeSearchField();
cantDeleteMessagesCount = 0;
}, null, resourcesProvider, null);
}, null, resourcesProvider, null, null);
} else if (id == forward) {
if (info != null) {
TLRPC.Chat chat = profileActivity.getMessagesController().getChat(info.id);
@ -4690,7 +4689,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
Bundle args1 = new Bundle();
args1.putBoolean("scrollToTopOnResume", true);
if (DialogObject.isEncryptedDialog(did)) {
if (!profileActivity.getEncryptedGroupUtils().putEncIdOrEncGroupIdInBundle(args1, did)) {
if (!profileActivity.getEncryptedGroupUtils().putEncIdOrEncGroupIdInBundleIfPossible(args1, did)) {
return true;
}
} else {

View file

@ -140,7 +140,6 @@ import org.telegram.messenger.partisan.appmigration.MigrationZipBuilder;
import org.telegram.messenger.partisan.fileprotection.FileProtectionTemporaryDisabledDialog;
import org.telegram.messenger.partisan.secretgroups.EncryptedGroup;
import org.telegram.messenger.partisan.verification.VerificationUpdatesChecker;
import org.telegram.messenger.voip.ConferenceCall;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.SerializedData;
import org.telegram.tgnet.TLObject;
@ -8334,7 +8333,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} else {
Bundle args = new Bundle();
if (DialogObject.isEncryptedDialog(dialogId)) {
if (!getEncryptedGroupUtils().putEncIdOrEncGroupIdInBundle(args, dialogId)) {
if (!getEncryptedGroupUtils().putEncIdOrEncGroupIdInBundleIfPossible(args, dialogId)) {
EncryptedGroup encryptedGroup = getMessagesController()
.getEncryptedGroup(DialogObject.getEncryptedChatId(dialogId));
getEncryptedGroupUtils().showSecretGroupJoinDialog(encryptedGroup, this, () -> {

View file

@ -6399,17 +6399,16 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter
titleTextView.setText(call.call.title, animated);
}
} else {
String title = UserConfig.getChatTitleOverride(getCurrentAccount(), currentChat);
if (currentChat != null && !title.equals(actionBar.getTitle())) {
if (currentChat != null && !UserConfig.getChatTitleOverride(getCurrentAccount(), currentChat).equals(actionBar.getTitle())) {
if (animated) {
actionBar.setTitleAnimated(title, true, 180);
actionBar.setTitleAnimated(UserConfig.getChatTitleOverride(getCurrentAccount(), currentChat), true, 180);
actionBar.getTitleTextView().setOnClickListener(v -> {
if (call != null && call.recording) {
showRecordHint(actionBar.getTitleTextView());
}
});
} else {
actionBar.setTitle(title);
actionBar.setTitle(UserConfig.getChatTitleOverride(getCurrentAccount(), currentChat));
}
if (ChatObject.isChannelOrGiga(currentChat)) {
if (isRtmpStream()) {

View file

@ -3234,7 +3234,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
}
} else if (push_enc_id != 0) {
Bundle args = new Bundle();
if (!new EncryptedGroupUtils(currentAccount).putEncIdOrEncGroupIdInBundle(args, DialogObject.makeEncryptedDialogId(push_enc_id))) {
if (!new EncryptedGroupUtils(currentAccount).putEncIdOrEncGroupIdInBundleIfPossible(args, DialogObject.makeEncryptedDialogId(push_enc_id))) {
return true;
}
if (new EncryptedGroupUtils(currentAccount).isNotInitializedEncryptedGroup(DialogObject.makeEncryptedDialogId(push_enc_id))) {
@ -6163,7 +6163,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
NotificationCenter.getInstance(account).postNotificationName(NotificationCenter.closeChats);
}
if (DialogObject.isEncryptedDialog(did)) {
if (!new EncryptedGroupUtils(account).putEncIdOrEncGroupIdInBundle(args, did)) {
if (!new EncryptedGroupUtils(account).putEncIdOrEncGroupIdInBundleIfPossible(args, did)) {
return false;
}
} else if (DialogObject.isUserDialog(did)) {

View file

@ -167,16 +167,7 @@ public class ChatRemoveCell extends FrameLayout implements AccountControllersPro
}
private void updateAvatar() {
if (item.getAvatarType().isPresent()) {
avatarDrawable.setAvatarType(item.getAvatarType().get());
avatarImageView.setImage(null, "50_50", avatarDrawable, item.getProfileObject());
} else if (item.getProfileObject() != null) {
avatarDrawable.setInfo(currentAccount, item.getProfileObject());
avatarImageView.setForUserOrChat(item.getProfileObject(), avatarDrawable);
} else {
avatarDrawable.setInfo(item.getId(), item.getDisplayName().toString(), "");
avatarImageView.setForUserOrChat(null, avatarDrawable);
}
item.applyAvatar(avatarImageView, avatarDrawable);
}
private void updateName() {

View file

@ -40,7 +40,6 @@ import org.telegram.messenger.Utilities;
import org.telegram.messenger.fakepasscode.FakePasscode;
import org.telegram.messenger.fakepasscode.RemoveChatsAction;
import org.telegram.messenger.partisan.Utils;
import org.telegram.messenger.partisan.secretgroups.EncryptedGroupUtils;
import org.telegram.messenger.support.LongSparseIntArray;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu;

View file

@ -3,8 +3,10 @@ package org.telegram.ui.RemoveChatsAction.items;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.DialogObject;
import org.telegram.messenger.partisan.secretgroups.EncryptedGroup;
import org.telegram.messenger.partisan.secretgroups.EncryptedGroupUtils;
import org.telegram.tgnet.TLObject;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView;
import java.util.Optional;
@ -50,7 +52,7 @@ public class EncryptedGroupItem extends Item {
}
@Override
public Optional<Integer> getAvatarType() {
return Optional.of(AvatarDrawable.AVATAR_TYPE_ANONYMOUS);
public void applyAvatar(BackupImageView avatarImageView, AvatarDrawable avatarDrawable) {
EncryptedGroupUtils.applyAvatar(avatarImageView, avatarDrawable, encryptedGroup);
}
}

View file

@ -1,6 +1,5 @@
package org.telegram.ui.RemoveChatsAction.items;
import org.telegram.messenger.AccountInstance;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.DialogObject;
import org.telegram.messenger.LocaleController;
@ -12,6 +11,8 @@ import org.telegram.messenger.partisan.AccountControllersProvider;
import org.telegram.messenger.partisan.secretgroups.EncryptedGroup;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView;
import java.util.Optional;
import java.util.stream.Collectors;
@ -127,8 +128,14 @@ public abstract class Item implements AccountControllersProvider {
|| lowercaseName.contains(" " + lowercaseQuery);
}
public Optional<Integer> getAvatarType() {
return Optional.empty();
public void applyAvatar(BackupImageView avatarImageView, AvatarDrawable avatarDrawable) {
if (getProfileObject() != null) {
avatarDrawable.setInfo(accountNum, getProfileObject());
avatarImageView.setForUserOrChat(getProfileObject(), avatarDrawable);
} else {
avatarDrawable.setInfo(getId(), getDisplayName().toString(), "");
avatarImageView.setForUserOrChat(null, avatarDrawable);
}
}
public OptionPermission getDeletePermission() {

View file

@ -1,6 +1,8 @@
package org.telegram.ui.RemoveChatsAction.items;
import org.telegram.tgnet.TLObject;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView;
import java.util.Optional;
@ -66,8 +68,8 @@ public class SearchItem extends Item {
}
@Override
public Optional<Integer> getAvatarType() {
return innerItem.getAvatarType();
public void applyAvatar(BackupImageView avatarImageView, AvatarDrawable avatarDrawable) {
innerItem.applyAvatar(avatarImageView, avatarDrawable);
}
@Override

View file

@ -7,6 +7,7 @@ import org.telegram.messenger.UserObject;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView;
import java.util.Optional;
@ -73,11 +74,12 @@ class UserItem extends AbstractUserItem {
}
@Override
public Optional<Integer> getAvatarType() {
public void applyAvatar(BackupImageView avatarImageView, AvatarDrawable avatarDrawable) {
if (isSelf()) {
return Optional.of(AvatarDrawable.AVATAR_TYPE_SAVED);
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
avatarImageView.setImage(null, "50_50", avatarDrawable, getProfileObject());
} else {
return super.getAvatarType();
super.applyAvatar(avatarImageView, avatarDrawable);
}
}
}

View file

@ -9576,4 +9576,5 @@
<string name="EncryptedGroupMemberRemovalConfirmation">Are you sure you want to remove this member from the secret group. All his messages will be deleted.</string>
<string name="EncryptedGroupAvatarChangeForbidden">You can\'t change avatar until the group is initialized.</string>
<string name="CantAddNewMemberToEncryptedGroupMessage">You must wait for confirmation from previous members before adding a new one.</string>
<string name="SlowSecretGroupCreationWarning">A secret group of 7 or more participants will be created longer than usual.</string>
</resources>