use of org.telegram.ui.Components.PhonebookShareAlert in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChannelAdminLogActivity method openVCard.
public void openVCard(TLRPC.User user, String vcard, String first_name, String last_name) {
try {
File f = AndroidUtilities.getSharingDirectory();
f.mkdirs();
f = new File(f, "vcard.vcf");
BufferedWriter writer = new BufferedWriter(new FileWriter(f));
writer.write(vcard);
writer.close();
showDialog(new PhonebookShareAlert(this, null, user, null, f, first_name, last_name));
} catch (Exception e) {
FileLog.e(e);
}
}
use of org.telegram.ui.Components.PhonebookShareAlert in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatActivity method openVCard.
public void openVCard(TLRPC.User user, String vcard, String first_name, String last_name) {
try {
File f = AndroidUtilities.getSharingDirectory();
f.mkdirs();
f = new File(f, "vcard.vcf");
BufferedWriter writer = new BufferedWriter(new FileWriter(f));
writer.write(vcard);
writer.close();
showDialog(new PhonebookShareAlert(this, null, user, null, f, first_name, last_name, themeDelegate));
} catch (Exception e) {
FileLog.e(e);
}
}
use of org.telegram.ui.Components.PhonebookShareAlert in project Telegram-FOSS by Telegram-FOSS-Team.
the class LaunchActivity method didSelectDialogs.
@Override
public void didSelectDialogs(DialogsActivity dialogsFragment, ArrayList<Long> dids, CharSequence message, boolean param) {
final int account = dialogsFragment != null ? dialogsFragment.getCurrentAccount() : currentAccount;
if (exportingChatUri != null) {
Uri uri = exportingChatUri;
ArrayList<Uri> documentsUris = documentsUrisArray != null ? new ArrayList<>(documentsUrisArray) : null;
final AlertDialog progressDialog = new AlertDialog(this, 3);
SendMessagesHelper.getInstance(account).prepareImportHistory(dids.get(0), exportingChatUri, documentsUrisArray, (result) -> {
if (result != 0) {
Bundle args = new Bundle();
args.putBoolean("scrollToTopOnResume", true);
if (!AndroidUtilities.isTablet()) {
NotificationCenter.getInstance(account).postNotificationName(NotificationCenter.closeChats);
}
if (DialogObject.isUserDialog(result)) {
args.putLong("user_id", result);
} else {
args.putLong("chat_id", -result);
}
ChatActivity fragment = new ChatActivity(args);
fragment.setOpenImport();
actionBarLayout.presentFragment(fragment, dialogsFragment != null || param, dialogsFragment == null, true, false);
} else {
documentsUrisArray = documentsUris;
if (documentsUrisArray == null) {
documentsUrisArray = new ArrayList<>();
}
documentsUrisArray.add(0, uri);
openDialogsToSend(true);
}
try {
progressDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
});
try {
progressDialog.showDelayed(300);
} catch (Exception ignore) {
}
} else {
boolean notify = dialogsFragment == null || dialogsFragment.notify;
final ChatActivity fragment;
if (dids.size() <= 1) {
final long did = dids.get(0);
Bundle args = new Bundle();
args.putBoolean("scrollToTopOnResume", true);
if (!AndroidUtilities.isTablet()) {
NotificationCenter.getInstance(account).postNotificationName(NotificationCenter.closeChats);
}
if (DialogObject.isEncryptedDialog(did)) {
args.putInt("enc_id", DialogObject.getEncryptedChatId(did));
} else if (DialogObject.isUserDialog(did)) {
args.putLong("user_id", did);
} else {
args.putLong("chat_id", -did);
}
if (!MessagesController.getInstance(account).checkCanOpenChat(args, dialogsFragment)) {
return;
}
fragment = new ChatActivity(args);
} else {
fragment = null;
}
int attachesCount = 0;
if (contactsToSend != null) {
attachesCount += contactsToSend.size();
}
if (videoPath != null) {
attachesCount++;
}
if (photoPathsArray != null) {
attachesCount += photoPathsArray.size();
}
if (documentsPathsArray != null) {
attachesCount += documentsPathsArray.size();
}
if (documentsUrisArray != null) {
attachesCount += documentsUrisArray.size();
}
if (videoPath == null && photoPathsArray == null && documentsPathsArray == null && documentsUrisArray == null && sendingText != null) {
attachesCount++;
}
for (int i = 0; i < dids.size(); i++) {
final long did = dids.get(i);
if (AlertsCreator.checkSlowMode(this, currentAccount, did, attachesCount > 1)) {
return;
}
}
if (contactsToSend != null && contactsToSend.size() == 1 && !mainFragmentsStack.isEmpty()) {
PhonebookShareAlert alert = new PhonebookShareAlert(mainFragmentsStack.get(mainFragmentsStack.size() - 1), null, null, contactsToSendUri, null, null, null);
alert.setDelegate((user, notify2, scheduleDate) -> {
if (fragment != null) {
actionBarLayout.presentFragment(fragment, true, false, true, false);
}
for (int i = 0; i < dids.size(); i++) {
SendMessagesHelper.getInstance(account).sendMessage(user, dids.get(i), null, null, null, null, notify2, scheduleDate);
}
});
mainFragmentsStack.get(mainFragmentsStack.size() - 1).showDialog(alert);
} else {
String captionToSend = null;
for (int i = 0; i < dids.size(); i++) {
final long did = dids.get(i);
AccountInstance accountInstance = AccountInstance.getInstance(UserConfig.selectedAccount);
boolean photosEditorOpened = false;
if (fragment != null) {
boolean withoutAnimation = dialogsFragment == null || (videoPath != null || (photoPathsArray != null && photoPathsArray.size() > 0));
actionBarLayout.presentFragment(fragment, dialogsFragment != null, withoutAnimation, true, false);
if (videoPath != null) {
fragment.openVideoEditor(videoPath, sendingText);
sendingText = null;
} else if (photoPathsArray != null && photoPathsArray.size() > 0) {
photosEditorOpened = fragment.openPhotosEditor(photoPathsArray, message == null || message.length() == 0 ? sendingText : message);
if (photosEditorOpened) {
sendingText = null;
}
}
} else {
if (videoPath != null) {
if (sendingText != null && sendingText.length() <= 1024) {
captionToSend = sendingText;
sendingText = null;
}
ArrayList<String> arrayList = new ArrayList<>();
arrayList.add(videoPath);
SendMessagesHelper.prepareSendingDocuments(accountInstance, arrayList, arrayList, null, captionToSend, null, did, null, null, null, null, notify, 0);
}
}
if (photoPathsArray != null && !photosEditorOpened) {
if (sendingText != null && sendingText.length() <= 1024 && photoPathsArray.size() == 1) {
photoPathsArray.get(0).caption = sendingText;
sendingText = null;
}
SendMessagesHelper.prepareSendingMedia(accountInstance, photoPathsArray, did, null, null, null, false, false, null, notify, 0);
}
if (documentsPathsArray != null || documentsUrisArray != null) {
if (sendingText != null && sendingText.length() <= 1024 && ((documentsPathsArray != null ? documentsPathsArray.size() : 0) + (documentsUrisArray != null ? documentsUrisArray.size() : 0)) == 1) {
captionToSend = sendingText;
sendingText = null;
}
SendMessagesHelper.prepareSendingDocuments(accountInstance, documentsPathsArray, documentsOriginalPathsArray, documentsUrisArray, captionToSend, documentsMimeType, did, null, null, null, null, notify, 0);
}
if (sendingLocation != null) {
SendMessagesHelper.prepareSendingLocation(accountInstance, sendingLocation, did);
sendingText = null;
}
if (sendingText != null) {
SendMessagesHelper.prepareSendingText(accountInstance, sendingText, did, true, 0);
}
if (contactsToSend != null && !contactsToSend.isEmpty()) {
for (int a = 0; a < contactsToSend.size(); a++) {
TLRPC.User user = contactsToSend.get(a);
SendMessagesHelper.getInstance(account).sendMessage(user, did, null, null, null, null, notify, 0);
}
}
if (!TextUtils.isEmpty(message)) {
SendMessagesHelper.prepareSendingText(accountInstance, message.toString(), did, notify, 0);
}
}
}
if (dialogsFragment != null && fragment == null) {
dialogsFragment.finishFragment();
}
}
photoPathsArray = null;
videoPath = null;
sendingText = null;
sendingLocation = null;
documentsPathsArray = null;
documentsOriginalPathsArray = null;
contactsToSend = null;
contactsToSendUri = null;
exportingChatUri = null;
}
Aggregations