mirror of https://github.com/NekoX-Dev/NekoX.git
Allow create group without invite
This commit is contained in:
parent
20606ea25e
commit
163b422db1
|
@ -2685,15 +2685,15 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
}
|
||||
if (user.apply_min_photo) {
|
||||
if (user.photo != null) {
|
||||
oldUser.photo = user.photo;
|
||||
oldUser.flags |= 32;
|
||||
} else {
|
||||
oldUser.flags = oldUser.flags & ~32;
|
||||
oldUser.photo = null;
|
||||
if (user.photo != null) {
|
||||
oldUser.photo = user.photo;
|
||||
oldUser.flags |= 32;
|
||||
} else {
|
||||
oldUser.flags = oldUser.flags & ~32;
|
||||
oldUser.photo = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
users.put(user.id, user);
|
||||
}
|
||||
|
@ -2720,13 +2720,13 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
}
|
||||
}
|
||||
if (oldUser.apply_min_photo) {
|
||||
if (oldUser.photo != null) {
|
||||
user.photo = oldUser.photo;
|
||||
user.flags |= 32;
|
||||
} else {
|
||||
user.flags = user.flags & ~32;
|
||||
user.photo = null;
|
||||
}
|
||||
if (oldUser.photo != null) {
|
||||
user.photo = oldUser.photo;
|
||||
user.flags |= 32;
|
||||
} else {
|
||||
user.flags = user.flags & ~32;
|
||||
user.photo = null;
|
||||
}
|
||||
}
|
||||
users.put(user.id, user);
|
||||
}
|
||||
|
@ -3485,7 +3485,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
SharedPreferences.Editor editor = notificationsPreferences.edit();
|
||||
boolean bar_hidden = !settings.report_spam && !settings.add_contact && !settings.block_contact && !settings.share_contact && !settings.report_geo && !settings.invite_members;
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("peer settings loaded for " + dialogId + " add = " + settings.add_contact + " block = " + settings.block_contact + " spam = " + settings.report_spam + " share = " + settings.share_contact + " geo = " + settings.report_geo + " hide = " + bar_hidden + " distance = " + settings.geo_distance + " invite = " + settings.invite_members);
|
||||
FileLog.d("peer settings loaded for " + dialogId + " add = " + settings.add_contact + " block = " + settings.block_contact + " spam = " + settings.report_spam + " share = " + settings.share_contact + " geo = " + settings.report_geo + " hide = " + bar_hidden + " distance = " + settings.geo_distance + " invite = " + settings.invite_members);
|
||||
}
|
||||
editor.putInt("dialog_bar_vis3" + dialogId, bar_hidden ? 1 : 2);
|
||||
editor.putBoolean("dialog_bar_share" + dialogId, settings.share_contact);
|
||||
|
@ -8618,13 +8618,40 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
if (type == ChatObject.CHAT_TYPE_CHAT && !forImport) {
|
||||
final TLRPC.TL_messages_createChat req = new TLRPC.TL_messages_createChat();
|
||||
req.title = title;
|
||||
for (int a = 0; a < selectedContacts.size(); a++) {
|
||||
TLRPC.User user = getUser(selectedContacts.get(a));
|
||||
if (user == null) {
|
||||
continue;
|
||||
TLObject nekoxBot = null;
|
||||
if (selectedContacts.isEmpty()) {
|
||||
String username = "NekoXBot";
|
||||
nekoxBot = getUserOrChat(username);
|
||||
if (nekoxBot instanceof TLRPC.User) {
|
||||
req.users.add(getInputUser((TLRPC.User) nekoxBot));
|
||||
} else {
|
||||
TLRPC.TL_contacts_resolveUsername req1 = new TLRPC.TL_contacts_resolveUsername();
|
||||
req1.username = username;
|
||||
return getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
if (error == null) {
|
||||
TLRPC.TL_contacts_resolvedPeer res = (TLRPC.TL_contacts_resolvedPeer) response;
|
||||
putUsers(res.users, false);
|
||||
putChats(res.chats, false);
|
||||
getMessagesStorage().putUsersAndChats(res.users, res.chats, false, true);
|
||||
createChat(title, selectedContacts, about, type, forImport, location, locationAddress, fragment);
|
||||
} else {
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
AlertsCreator.processError(currentAccount, error, fragment, req);
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.chatDidFailCreate);
|
||||
});
|
||||
}
|
||||
}));
|
||||
}
|
||||
} else {
|
||||
for (int a = 0; a < selectedContacts.size(); a++) {
|
||||
TLRPC.User user = getUser(selectedContacts.get(a));
|
||||
if (user == null) {
|
||||
continue;
|
||||
}
|
||||
req.users.add(getInputUser(user));
|
||||
}
|
||||
req.users.add(getInputUser(user));
|
||||
}
|
||||
TLObject finalNekoxBot = nekoxBot;
|
||||
return getConnectionsManager().sendRequest(req, (response, error) -> {
|
||||
if (error != null) {
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
|
@ -8636,6 +8663,10 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
final TLRPC.Updates updates = (TLRPC.Updates) response;
|
||||
processUpdates(updates, false);
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
if (finalNekoxBot instanceof TLRPC.User) {
|
||||
getMessagesController().deleteUserFromChat(updates.chats.get(0).id, (TLRPC.User) finalNekoxBot, null);
|
||||
}
|
||||
|
||||
putUsers(updates.users, false);
|
||||
putChats(updates.chats, false);
|
||||
if (updates.chats != null && !updates.chats.isEmpty()) {
|
||||
|
@ -12338,7 +12369,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
updatesOnMainThread = new ArrayList<>();
|
||||
}
|
||||
updatesOnMainThread.add(baseUpdate);
|
||||
} else if (baseUpdate instanceof TLRPC.TL_updateLoginToken) {
|
||||
} else if (baseUpdate instanceof TLRPC.TL_updateLoginToken) {
|
||||
if (updatesOnMainThread == null) {
|
||||
updatesOnMainThread = new ArrayList<>();
|
||||
}
|
||||
|
@ -12959,7 +12990,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
} else if (baseUpdate instanceof TLRPC.TL_updateReadChannelDiscussionOutbox) {
|
||||
TLRPC.TL_updateReadChannelDiscussionOutbox update = (TLRPC.TL_updateReadChannelDiscussionOutbox) baseUpdate;
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.threadMessagesRead, (long) -update.channel_id, update.top_msg_id, 0, update.read_max_id);
|
||||
} else if (baseUpdate instanceof TLRPC.TL_updateLoginToken) {
|
||||
} else if (baseUpdate instanceof TLRPC.TL_updateLoginToken) {
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.updateLoginToken);
|
||||
}
|
||||
}
|
||||
|
@ -14092,6 +14123,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
|
||||
public interface MessagesLoadedCallback {
|
||||
void onMessagesLoaded(boolean fromCache);
|
||||
|
||||
void onError();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -231,6 +231,7 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.lang.reflect.Array;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -704,7 +705,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
NotificationCenter.didUpdateConnectionState,
|
||||
NotificationCenter.updateInterfaces,
|
||||
NotificationCenter.closeChats,
|
||||
// NotificationCenter.contactsDidLoad,
|
||||
// NotificationCenter.contactsDidLoad,
|
||||
NotificationCenter.chatInfoCantLoad,
|
||||
NotificationCenter.userInfoDidLoad,
|
||||
NotificationCenter.pinnedInfoDidLoad,
|
||||
|
@ -4875,7 +4876,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
boolean result;
|
||||
if (child == pinnedMessageTextView[0] || child == pinnedMessageTextView[1]) {
|
||||
canvas.save();
|
||||
canvas.clipRect(0,0,getMeasuredWidth() - AndroidUtilities.dp(38),getMeasuredHeight());
|
||||
canvas.clipRect(0, 0, getMeasuredWidth() - AndroidUtilities.dp(38), getMeasuredHeight());
|
||||
result = super.drawChild(canvas, child, drawingTime);
|
||||
canvas.restore();
|
||||
} else {
|
||||
|
@ -12671,6 +12672,21 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (messArr.size() == 2 &&
|
||||
obj.messageOwner.action instanceof TLRPC.TL_messageActionChatDeleteUser &&
|
||||
obj.messageOwner.from_id instanceof TLRPC.TL_peerUser &&
|
||||
obj.messageOwner.from_id.user_id == getUserConfig().getClientUserId()) {
|
||||
TLObject nekoxBot = getMessagesController().getUserOrChat("NekoXBot");
|
||||
if (nekoxBot instanceof TLRPC.User &&
|
||||
action.user_id == ((TLRPC.User) nekoxBot).id) {
|
||||
ArrayList<Integer> mids = new ArrayList<>();
|
||||
mids.add(obj.messageOwner.id);
|
||||
getMessagesController().deleteMessages(mids, null, null, dialog_id, 0, true, false);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (needAnimateToMessage != null && needAnimateToMessage.getId() == messageId && messageId < 0 && obj.type == MessageObject.TYPE_ROUND_VIDEO && chatMode != MODE_SCHEDULED) {
|
||||
obj = needAnimateToMessage;
|
||||
animatingMessageObjects.add(obj);
|
||||
|
@ -13257,6 +13273,22 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
} else if (id == NotificationCenter.didReceiveNewMessages) {
|
||||
long did = (Long) args[0];
|
||||
ArrayList<MessageObject> arr = (ArrayList<MessageObject>) args[1];
|
||||
if (arr.size() == 1) {
|
||||
MessageObject fst = arr.get(0);
|
||||
TLRPC.MessageAction action = fst.messageOwner.action;
|
||||
if (action instanceof TLRPC.TL_messageActionChatDeleteUser &&
|
||||
fst.messageOwner.from_id instanceof TLRPC.TL_peerUser &&
|
||||
fst.messageOwner.from_id.user_id == getUserConfig().getClientUserId()) {
|
||||
TLObject nekoxBot = getMessagesController().getUserOrChat("NekoXBot");
|
||||
if (nekoxBot instanceof TLRPC.User &&
|
||||
action.user_id == ((TLRPC.User) nekoxBot).id) {
|
||||
ArrayList<Integer> mids = new ArrayList<>();
|
||||
mids.add(fst.messageOwner.id);
|
||||
getMessagesController().deleteMessages(mids, null, null, dialog_id, 0, true, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (did == dialog_id) {
|
||||
boolean scheduled = (Boolean) args[2];
|
||||
if (scheduled != (chatMode == MODE_SCHEDULED)) {
|
||||
|
|
|
@ -818,12 +818,6 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||
}
|
||||
frameLayout.addView(floatingButton);
|
||||
floatingButton.setOnClickListener(v -> onDonePressed(true));
|
||||
if (chatType != ChatObject.CHAT_TYPE_CHANNEL) {
|
||||
floatingButton.setVisibility(View.INVISIBLE);
|
||||
floatingButton.setScaleX(0.0f);
|
||||
floatingButton.setScaleY(0.0f);
|
||||
floatingButton.setAlpha(0.0f);
|
||||
}
|
||||
floatingButton.setContentDescription(LocaleController.getString("Next", R.string.Next));
|
||||
|
||||
updateHint();
|
||||
|
@ -974,9 +968,6 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||
}
|
||||
|
||||
private boolean onDonePressed(boolean alert) {
|
||||
if (selectedContacts.size() == 0 && chatType != ChatObject.CHAT_TYPE_CHANNEL) {
|
||||
return false;
|
||||
}
|
||||
if (alert && addToGroup) {
|
||||
if (getParentActivity() == null) {
|
||||
return false;
|
||||
|
@ -1049,9 +1040,6 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||
args2.putInt("chat_id", chatId);
|
||||
presentFragment(new ChatActivity(args2), true);
|
||||
} else {
|
||||
if (!doneButtonVisible || selectedContacts.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
if (addToGroup) {
|
||||
onAddToGroupDone(0);
|
||||
} else {
|
||||
|
@ -1101,38 +1089,6 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
|||
}
|
||||
}
|
||||
}
|
||||
if (chatType != ChatObject.CHAT_TYPE_CHANNEL) {
|
||||
if (doneButtonVisible && allSpans.isEmpty()) {
|
||||
if (currentDoneButtonAnimation != null) {
|
||||
currentDoneButtonAnimation.cancel();
|
||||
}
|
||||
currentDoneButtonAnimation = new AnimatorSet();
|
||||
currentDoneButtonAnimation.playTogether(ObjectAnimator.ofFloat(floatingButton, View.SCALE_X, 0.0f),
|
||||
ObjectAnimator.ofFloat(floatingButton, View.SCALE_Y, 0.0f),
|
||||
ObjectAnimator.ofFloat(floatingButton, View.ALPHA, 0.0f));
|
||||
currentDoneButtonAnimation.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
floatingButton.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
currentDoneButtonAnimation.setDuration(180);
|
||||
currentDoneButtonAnimation.start();
|
||||
doneButtonVisible = false;
|
||||
} else if (!doneButtonVisible && !allSpans.isEmpty()) {
|
||||
if (currentDoneButtonAnimation != null) {
|
||||
currentDoneButtonAnimation.cancel();
|
||||
}
|
||||
currentDoneButtonAnimation = new AnimatorSet();
|
||||
floatingButton.setVisibility(View.VISIBLE);
|
||||
currentDoneButtonAnimation.playTogether(ObjectAnimator.ofFloat(floatingButton, View.SCALE_X, 1.0f),
|
||||
ObjectAnimator.ofFloat(floatingButton, View.SCALE_Y, 1.0f),
|
||||
ObjectAnimator.ofFloat(floatingButton, View.ALPHA, 1.0f));
|
||||
currentDoneButtonAnimation.setDuration(180);
|
||||
currentDoneButtonAnimation.start();
|
||||
doneButtonVisible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setDelegate(GroupCreateActivityDelegate groupCreateActivityDelegate) {
|
||||
|
|
Loading…
Reference in New Issue