use of org.telegram.ui.DialogsActivity in project Telegram-FOSS by Telegram-FOSS-Team.
the class SharedMediaLayout method onActionBarItemClick.
public void onActionBarItemClick(View v, int id) {
if (id == delete) {
TLRPC.Chat currentChat = null;
TLRPC.User currentUser = null;
TLRPC.EncryptedChat currentEncryptedChat = null;
if (DialogObject.isEncryptedDialog(dialog_id)) {
currentEncryptedChat = profileActivity.getMessagesController().getEncryptedChat(DialogObject.getEncryptedChatId(dialog_id));
} else if (DialogObject.isUserDialog(dialog_id)) {
currentUser = profileActivity.getMessagesController().getUser(dialog_id);
} else {
currentChat = profileActivity.getMessagesController().getChat(-dialog_id);
}
AlertsCreator.createDeleteMessagesAlert(profileActivity, currentUser, currentChat, currentEncryptedChat, null, mergeDialogId, null, selectedFiles, null, false, 1, () -> {
showActionMode(false);
actionBar.closeSearchField();
cantDeleteMessagesCount = 0;
}, null, null);
} else if (id == forward) {
if (info != null) {
TLRPC.Chat chat = profileActivity.getMessagesController().getChat(info.id);
if (profileActivity.getMessagesController().isChatNoForwards(chat)) {
if (fwdRestrictedHint != null) {
fwdRestrictedHint.setText(ChatObject.isChannel(chat) && !chat.megagroup ? LocaleController.getString("ForwardsRestrictedInfoChannel", R.string.ForwardsRestrictedInfoChannel) : LocaleController.getString("ForwardsRestrictedInfoGroup", R.string.ForwardsRestrictedInfoGroup));
fwdRestrictedHint.showForView(v, true);
}
return;
}
}
if (hasNoforwardsMessage()) {
if (fwdRestrictedHint != null) {
fwdRestrictedHint.setText(LocaleController.getString("ForwardsRestrictedInfoBot", R.string.ForwardsRestrictedInfoBot));
fwdRestrictedHint.showForView(v, true);
}
return;
}
Bundle args = new Bundle();
args.putBoolean("onlySelect", true);
args.putInt("dialogsType", 3);
DialogsActivity fragment = new DialogsActivity(args);
fragment.setDelegate((fragment1, dids, message, param) -> {
ArrayList<MessageObject> fmessages = new ArrayList<>();
for (int a = 1; a >= 0; a--) {
ArrayList<Integer> ids = new ArrayList<>();
for (int b = 0; b < selectedFiles[a].size(); b++) {
ids.add(selectedFiles[a].keyAt(b));
}
Collections.sort(ids);
for (Integer id1 : ids) {
if (id1 > 0) {
fmessages.add(selectedFiles[a].get(id1));
}
}
selectedFiles[a].clear();
}
cantDeleteMessagesCount = 0;
showActionMode(false);
if (dids.size() > 1 || dids.get(0) == profileActivity.getUserConfig().getClientUserId() || message != null) {
updateRowsSelection();
for (int a = 0; a < dids.size(); a++) {
long did = dids.get(a);
if (message != null) {
profileActivity.getSendMessagesHelper().sendMessage(message.toString(), did, null, null, null, true, null, null, null, true, 0, null);
}
profileActivity.getSendMessagesHelper().sendMessage(fmessages, did, false, false, true, 0);
}
fragment1.finishFragment();
} else {
long did = dids.get(0);
Bundle args1 = new Bundle();
args1.putBoolean("scrollToTopOnResume", true);
if (DialogObject.isEncryptedDialog(did)) {
args1.putInt("enc_id", DialogObject.getEncryptedChatId(did));
} else {
if (DialogObject.isUserDialog(did)) {
args1.putLong("user_id", did);
} else {
args1.putLong("chat_id", -did);
}
if (!profileActivity.getMessagesController().checkCanOpenChat(args1, fragment1)) {
return;
}
}
profileActivity.getNotificationCenter().postNotificationName(NotificationCenter.closeChats);
ChatActivity chatActivity = new ChatActivity(args1);
fragment1.presentFragment(chatActivity, true);
chatActivity.showFieldPanelForForward(true, fmessages);
}
});
profileActivity.presentFragment(fragment);
} else if (id == gotochat) {
if (selectedFiles[0].size() + selectedFiles[1].size() != 1) {
return;
}
MessageObject messageObject = selectedFiles[selectedFiles[0].size() == 1 ? 0 : 1].valueAt(0);
Bundle args = new Bundle();
long dialogId = messageObject.getDialogId();
if (DialogObject.isEncryptedDialog(dialogId)) {
args.putInt("enc_id", DialogObject.getEncryptedChatId(dialogId));
} else if (DialogObject.isUserDialog(dialogId)) {
args.putLong("user_id", dialogId);
} else {
TLRPC.Chat chat = profileActivity.getMessagesController().getChat(-dialogId);
if (chat != null && chat.migrated_to != null) {
args.putLong("migrated_to", dialogId);
dialogId = -chat.migrated_to.channel_id;
}
args.putLong("chat_id", -dialogId);
}
args.putInt("message_id", messageObject.getId());
args.putBoolean("need_remove_previous_same_chat_activity", false);
profileActivity.presentFragment(new ChatActivity(args), false);
}
}
Aggregations