Java Code Examples for org.telegram.messenger.UserConfig#getInstance()

The following examples show how to use org.telegram.messenger.UserConfig#getInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContactsAdapter.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void setSortType(int value) {
    sortType = value;
    if (sortType == 2) {
        if (onlineContacts == null) {
            onlineContacts = new ArrayList<>(ContactsController.getInstance(currentAccount).contacts);
            int selfId = UserConfig.getInstance(currentAccount).clientUserId;
            for (int a = 0, N = onlineContacts.size(); a < N; a++) {
                if (onlineContacts.get(a).user_id == selfId) {
                    onlineContacts.remove(a);
                    break;
                }
            }
        }
        sortOnlineContacts();
    } else {
        notifyDataSetChanged();
    }
}
 
Example 2
Source File: LoginActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void onAuthSuccess(TLRPC.TL_auth_authorization res)
{
    ConnectionsManager.getInstance(currentAccount).setUserId(res.user.id);
    UserConfig.getInstance(currentAccount).clearConfig();
    MessagesController.getInstance(currentAccount).cleanup();
    UserConfig.getInstance(currentAccount).syncContacts = syncContacts;
    UserConfig.getInstance(currentAccount).setCurrentUser(res.user);
    UserConfig.getInstance(currentAccount).saveConfig(true);
    MessagesStorage.getInstance(currentAccount).cleanup(true);
    ArrayList<TLRPC.User> users = new ArrayList<>();
    users.add(res.user);
    MessagesStorage.getInstance(currentAccount).putUsersAndChats(users, null, true, true);
    MessagesController.getInstance(currentAccount).putUser(res.user, false);
    ContactsController.getInstance(currentAccount).checkAppAccount();
    MessagesController.getInstance(currentAccount).getBlockedUsers(true);
    MessagesController.getInstance(currentAccount).checkProxyInfo(true);
    ConnectionsManager.getInstance(currentAccount).updateDcSettings();
    needFinishActivity();
}
 
Example 3
Source File: PaymentFormActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public PaymentFormActivity(TLRPC.TL_payments_paymentForm form, MessageObject message) {
    int step;
    if (form.invoice.shipping_address_requested || form.invoice.email_requested || form.invoice.name_requested || form.invoice.phone_requested) {
        step = 0;
    } else if (form.saved_credentials != null) {
        if (UserConfig.getInstance(currentAccount).tmpPassword != null) {
            if (UserConfig.getInstance(currentAccount).tmpPassword.valid_until < ConnectionsManager.getInstance(currentAccount).getCurrentTime() + 60) {
                UserConfig.getInstance(currentAccount).tmpPassword = null;
                UserConfig.getInstance(currentAccount).saveConfig(false);
            }
        }
        if (UserConfig.getInstance(currentAccount).tmpPassword != null) {
            step = 4;
        } else {
            step = 3;
        }
    } else {
        step = 2;
    }
    init(form, message, step, null, null, null, null, null, false, null);
}
 
Example 4
Source File: ContactsActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.M)
private void askForPermissons(boolean alert) {
    Activity activity = getParentActivity();
    if (activity == null || !UserConfig.getInstance(currentAccount).syncContacts || activity.checkSelfPermission(Manifest.permission.READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) {
        return;
    }
    if (alert && askAboutContacts) {
        AlertDialog.Builder builder = AlertsCreator.createContactsPermissionDialog(activity, new MessagesStorage.IntCallback() {
            @Override
            public void run(int param) {
                askAboutContacts = param != 0;
                MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts).commit();
                askForPermissons(false);
            }
        });
        showDialog(builder.create());
        return;
    }
    ArrayList<String> permissons = new ArrayList<>();
    permissons.add(Manifest.permission.READ_CONTACTS);
    permissons.add(Manifest.permission.WRITE_CONTACTS);
    permissons.add(Manifest.permission.GET_ACCOUNTS);
    String[] items = permissons.toArray(new String[permissons.size()]);
    activity.requestPermissions(items, 1);
}
 
Example 5
Source File: PaymentFormActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public PaymentFormActivity(TLRPC.TL_payments_paymentForm form, MessageObject message) {
    int step;
    if (form.invoice.shipping_address_requested || form.invoice.email_requested || form.invoice.name_requested || form.invoice.phone_requested) {
        step = 0;
    } else if (form.saved_credentials != null) {
        if (UserConfig.getInstance(currentAccount).tmpPassword != null) {
            if (UserConfig.getInstance(currentAccount).tmpPassword.valid_until < ConnectionsManager.getInstance(currentAccount).getCurrentTime() + 60) {
                UserConfig.getInstance(currentAccount).tmpPassword = null;
                UserConfig.getInstance(currentAccount).saveConfig(false);
            }
        }
        if (UserConfig.getInstance(currentAccount).tmpPassword != null) {
            step = 4;
        } else {
            step = 3;
        }
    } else {
        step = 2;
    }
    init(form, message, step, null, null, null, null, null, false, null);
}
 
Example 6
Source File: PrivacySettingsActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void loadPasswordSettings() {
    if (UserConfig.getInstance(currentAccount).hasSecureData) {
        return;
    }
    TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword();
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
        if (response != null) {
            TLRPC.TL_account_password password = (TLRPC.TL_account_password) response;
            if (password.has_secure_values) {
                AndroidUtilities.runOnUIThread(() -> {
                    UserConfig.getInstance(currentAccount).hasSecureData = true;
                    UserConfig.getInstance(currentAccount).saveConfig(false);
                    updateRows();
                });
            }
        }
    }, ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin);
}
 
Example 7
Source File: PaymentFormActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public PaymentFormActivity(TLRPC.TL_payments_paymentForm form, MessageObject message) {
    int step;
    if (form.invoice.shipping_address_requested || form.invoice.email_requested || form.invoice.name_requested || form.invoice.phone_requested) {
        step = 0;
    } else if (form.saved_credentials != null) {
        if (UserConfig.getInstance(currentAccount).tmpPassword != null) {
            if (UserConfig.getInstance(currentAccount).tmpPassword.valid_until < ConnectionsManager.getInstance(currentAccount).getCurrentTime() + 60) {
                UserConfig.getInstance(currentAccount).tmpPassword = null;
                UserConfig.getInstance(currentAccount).saveConfig(false);
            }
        }
        if (UserConfig.getInstance(currentAccount).tmpPassword != null) {
            step = 4;
        } else {
            step = 3;
        }
    } else {
        step = 2;
    }
    init(form, message, step, null, null, null, null, null, false, null);
}
 
Example 8
Source File: ContactsActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean onFragmentCreate() {
    super.onFragmentCreate();
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.contactsDidLoad);
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.updateInterfaces);
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.encryptedChatCreated);
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.closeChats);
    checkPermission = UserConfig.getInstance(currentAccount).syncContacts;
    if (arguments != null) {
        onlyUsers = arguments.getBoolean("onlyUsers", false);
        destroyAfterSelect = arguments.getBoolean("destroyAfterSelect", false);
        returnAsResult = arguments.getBoolean("returnAsResult", false);
        createSecretChat = arguments.getBoolean("createSecretChat", false);
        selectAlertString = arguments.getString("selectAlertString");
        allowUsernameSearch = arguments.getBoolean("allowUsernameSearch", true);
        needForwardCount = arguments.getBoolean("needForwardCount", true);
        allowBots = arguments.getBoolean("allowBots", true);
        allowSelf = arguments.getBoolean("allowSelf", true);
        channelId = arguments.getInt("channelId", 0);
        needFinishFragment = arguments.getBoolean("needFinishFragment", true);
        chatId = arguments.getInt("chat_id", 0);
        disableSections = arguments.getBoolean("disableSections", false);
        resetDelegate = arguments.getBoolean("resetDelegate", false);
    } else {
        needPhonebook = true;
    }

    if (!createSecretChat && !returnAsResult) {
        sortByName = SharedConfig.sortContactsByName;
    }

    getContactsController().checkInviteText();
    getContactsController().reloadContactsStatusesMaybe();


    return true;
}
 
Example 9
Source File: ContactsActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.M)
private void askForPermissons(boolean alert) {
    Activity activity = getParentActivity();
    if (activity == null || !UserConfig.getInstance(currentAccount).syncContacts || activity.checkSelfPermission(Manifest.permission.READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) {
        return;
    }
    if (alert && askAboutContacts) {
        AlertDialog.Builder builder = AlertsCreator.createContactsPermissionDialog(activity, param -> {
            askAboutContacts = param != 0;
            if (param == 0) {
                return;
            }
            askForPermissons(false);
        });
        showDialog(builder.create());
        return;
    }
    ArrayList<String> permissons = new ArrayList<>();
    permissons.add(Manifest.permission.READ_CONTACTS);
    permissons.add(Manifest.permission.WRITE_CONTACTS);
    permissons.add(Manifest.permission.GET_ACCOUNTS);
    String[] items = permissons.toArray(new String[0]);
    try {
        activity.requestPermissions(items, 1);
    } catch (Exception e) {
        FileLog.e(e);
    }
}
 
Example 10
Source File: InviteContactsActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean onFragmentCreate() {
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.contactsImported);
    fetchContacts();
    if (!UserConfig.getInstance(currentAccount).contactsReimported) {
        ContactsController.getInstance(currentAccount).forceImportContacts();
        UserConfig.getInstance(currentAccount).contactsReimported = true;
        UserConfig.getInstance(currentAccount).saveConfig(false);
    }
    return super.onFragmentCreate();
}
 
Example 11
Source File: PrivacySettingsActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onFragmentDestroy() {
    super.onFragmentDestroy();
    NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.privacyRulesUpdated);
    if (currentSync != newSync) {
        UserConfig.getInstance(currentAccount).syncContacts = newSync;
        UserConfig.getInstance(currentAccount).saveConfig(false);
        if (newSync) {
            ContactsController.getInstance(currentAccount).forceImportContacts();
            if (getParentActivity() != null) {
                Toast.makeText(getParentActivity(), LocaleController.getString("SyncContactsAdded", R.string.SyncContactsAdded), Toast.LENGTH_SHORT).show();
            }
        }
    }
    if (newSuggest != currentSuggest) {
        if (!newSuggest) {
            DataQuery.getInstance(currentAccount).clearTopPeers();
        }
        UserConfig.getInstance(currentAccount).suggestContacts = newSuggest;
        UserConfig.getInstance(currentAccount).saveConfig(false);
        TLRPC.TL_contacts_toggleTopPeers req = new TLRPC.TL_contacts_toggleTopPeers();
        req.enabled = newSuggest;
        ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {

        });
    }
}
 
Example 12
Source File: ContactsActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.M)
private void askForPermissons(boolean alert) {
    Activity activity = getParentActivity();
    if (activity == null || !UserConfig.getInstance(currentAccount).syncContacts || activity.checkSelfPermission(Manifest.permission.READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) {
        return;
    }
    if (alert && askAboutContacts) {
        AlertDialog.Builder builder = AlertsCreator.createContactsPermissionDialog(activity, param -> {
            askAboutContacts = param != 0;
            if (param == 0) {
                return;
            }
            askForPermissons(false);
        });
        showDialog(builder.create());
        return;
    }
    ArrayList<String> permissons = new ArrayList<>();
    permissons.add(Manifest.permission.READ_CONTACTS);
    permissons.add(Manifest.permission.WRITE_CONTACTS);
    permissons.add(Manifest.permission.GET_ACCOUNTS);
    String[] items = permissons.toArray(new String[0]);
    try {
        activity.requestPermissions(items, 1);
    } catch (Exception e) {
        FileLog.e(e);
    }
}
 
Example 13
Source File: InviteContactsActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean onFragmentCreate() {
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.contactsImported);
    fetchContacts();
    if (!UserConfig.getInstance(currentAccount).contactsReimported) {
        ContactsController.getInstance(currentAccount).forceImportContacts();
        UserConfig.getInstance(currentAccount).contactsReimported = true;
        UserConfig.getInstance(currentAccount).saveConfig(false);
    }
    return super.onFragmentCreate();
}
 
Example 14
Source File: ContactsActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean onFragmentCreate() {
    super.onFragmentCreate();
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.contactsDidLoaded);
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.updateInterfaces);
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.encryptedChatCreated);
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.closeChats);
    MessagesController.getGlobalNotificationsSettings().getBoolean("askAboutContacts", true);
    checkPermission = UserConfig.getInstance(currentAccount).syncContacts;
    if (arguments != null) {
        onlyUsers = getArguments().getBoolean("onlyUsers", false);
        destroyAfterSelect = arguments.getBoolean("destroyAfterSelect", false);
        returnAsResult = arguments.getBoolean("returnAsResult", false);
        createSecretChat = arguments.getBoolean("createSecretChat", false);
        selectAlertString = arguments.getString("selectAlertString");
        allowUsernameSearch = arguments.getBoolean("allowUsernameSearch", true);
        needForwardCount = arguments.getBoolean("needForwardCount", true);
        allowBots = arguments.getBoolean("allowBots", true);
        addingToChannel = arguments.getBoolean("addingToChannel", false);
        needFinishFragment = arguments.getBoolean("needFinishFragment", true);
        chat_id = arguments.getInt("chat_id", 0);
    } else {
        needPhonebook = true;
    }

    ContactsController.getInstance(currentAccount).checkInviteText();

    return true;
}
 
Example 15
Source File: InviteContactsActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean onFragmentCreate() {
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.contactsImported);
    fetchContacts();
    if (!UserConfig.getInstance(currentAccount).contactsReimported) {
        ContactsController.getInstance(currentAccount).forceImportContacts();
        UserConfig.getInstance(currentAccount).contactsReimported = true;
        UserConfig.getInstance(currentAccount).saveConfig(false);
    }
    return super.onFragmentCreate();
}
 
Example 16
Source File: PrivacySettingsActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void updateRows() {
    rowCount = 0;
    privacySectionRow = rowCount++;
    blockedRow = rowCount++;
    lastSeenRow = rowCount++;
    callsRow = rowCount++;
    groupsRow = rowCount++;
    groupsDetailRow = rowCount++;
    securitySectionRow = rowCount++;
    passcodeRow = rowCount++;
    passwordRow = rowCount++;
    sessionsRow = rowCount++;
    sessionsDetailRow = rowCount++;
    advancedSectionRow = rowCount++;
    clearDraftsRow = rowCount++;
    deleteAccountRow = rowCount++;
    deleteAccountDetailRow = rowCount++;
    botsSectionRow = rowCount++;
    if (UserConfig.getInstance(currentAccount).hasSecureData) {
        passportRow = rowCount++;
    } else {
        passportRow = -1;
    }
    paymentsClearRow = rowCount++;
    webSessionsRow = rowCount++;
    botsDetailRow = rowCount++;
    contactsSectionRow = rowCount++;
    contactsDeleteRow = rowCount++;
    contactsSyncRow = rowCount++;
    contactsSuggestRow = rowCount++;
    contactsDetailRow = rowCount++;
    callsSectionRow = rowCount++;
    callsP2PRow = rowCount++;
    callsDetailRow = rowCount++;
    secretSectionRow = rowCount++;
    secretMapRow = rowCount++;
    secretWebpageRow = rowCount++;
    secretDetailRow = rowCount++;
    if (listAdapter != null) {
        listAdapter.notifyDataSetChanged();
    }
}
 
Example 17
Source File: DialogsAdapter.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public int getItemCount() {
    ArrayList<TLRPC.Dialog> array = DialogsActivity.getDialogsArray(currentAccount, dialogsType, folderId, dialogsListFrozen);
    int dialogsCount = array.size();
    if (dialogsType != 7 && dialogsType != 8 && dialogsCount == 0 && (folderId != 0 || MessagesController.getInstance(currentAccount).isLoadingDialogs(folderId))) {
        onlineContacts = null;
        if (folderId == 1 && showArchiveHint) {
            return (currentCount = 2);
        }
        return (currentCount = 0);
    }
    int count = dialogsCount;
    if (dialogsType == 7 || dialogsType == 8) {
        if (dialogsCount == 0) {
            count++;
        }
    } else {
        if (!MessagesController.getInstance(currentAccount).isDialogsEndReached(folderId) || dialogsCount == 0) {
            count++;
        }
    }
    boolean hasContacts = false;
    if (hasHints) {
        count += 2 + MessagesController.getInstance(currentAccount).hintDialogs.size();
    } else if (dialogsType == 0 && dialogsCount == 0 && folderId == 0) {
        if (ContactsController.getInstance(currentAccount).contacts.isEmpty() && ContactsController.getInstance(currentAccount).isLoadingContacts()) {
            onlineContacts = null;
            return (currentCount = 0);
        }

        if (!ContactsController.getInstance(currentAccount).contacts.isEmpty()) {
            if (onlineContacts == null || prevContactsCount != ContactsController.getInstance(currentAccount).contacts.size()) {
                onlineContacts = new ArrayList<>(ContactsController.getInstance(currentAccount).contacts);
                prevContactsCount = onlineContacts.size();
                int selfId = UserConfig.getInstance(currentAccount).clientUserId;
                for (int a = 0, N = onlineContacts.size(); a < N; a++) {
                    if (onlineContacts.get(a).user_id == selfId) {
                        onlineContacts.remove(a);
                        break;
                    }
                }
                sortOnlineContacts(false);
            }
            count += onlineContacts.size() + 2;
            hasContacts = true;
        }
    }
    if (!hasContacts && onlineContacts != null) {
        onlineContacts = null;
    }
    if (folderId == 1 && showArchiveHint) {
        count += 2;
    }
    if (folderId == 0 && dialogsCount != 0) {
        count++;
    }
    currentCount = count;
    return count;
}
 
Example 18
Source File: DialogsActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.M)
private void askForPermissons(boolean alert)
{
    Activity activity = getParentActivity();
    if (activity == null)
    {
        return;
    }
    ArrayList<String> permissons = new ArrayList<>();
    if (UserConfig.getInstance(currentAccount).syncContacts && askAboutContacts && activity.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED)
    {
        if (alert)
        {
            AlertDialog.Builder builder = AlertsCreator.createContactsPermissionDialog(activity, param ->
            {
                askAboutContacts = param != 0;
                MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts).apply();
                askForPermissons(false);
            });
            showDialog(permissionDialog = builder.create());
            return;
        }
        permissons.add(Manifest.permission.READ_CONTACTS);
        permissons.add(Manifest.permission.WRITE_CONTACTS);
        permissons.add(Manifest.permission.GET_ACCOUNTS);
    }
    if (activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)
    {
        permissons.add(Manifest.permission.READ_EXTERNAL_STORAGE);
        permissons.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
    }
    if (permissons.isEmpty())
    {
        return;
    }
    String[] items = permissons.toArray(new String[permissons.size()]);
    try
    {
        activity.requestPermissions(items, 1);
    }
    catch (Exception ignore)
    {
    }
}
 
Example 19
Source File: DialogsActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.M)
private void askForPermissons(boolean alert)
{
    Activity activity = getParentActivity();
    if (activity == null)
    {
        return;
    }
    ArrayList<String> permissons = new ArrayList<>();
    if (UserConfig.getInstance(currentAccount).syncContacts && askAboutContacts && activity.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED)
    {
        if (alert)
        {
            AlertDialog.Builder builder = AlertsCreator.createContactsPermissionDialog(activity, param ->
            {
                askAboutContacts = param != 0;
                MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts).apply();
                askForPermissons(false);
            });
            showDialog(permissionDialog = builder.create());
            return;
        }
        permissons.add(Manifest.permission.READ_CONTACTS);
        permissons.add(Manifest.permission.WRITE_CONTACTS);
        permissons.add(Manifest.permission.GET_ACCOUNTS);
    }
    if (activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)
    {
        permissons.add(Manifest.permission.READ_EXTERNAL_STORAGE);
        permissons.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
    }
    if (permissons.isEmpty())
    {
        return;
    }
    String[] items = permissons.toArray(new String[permissons.size()]);
    try
    {
        activity.requestPermissions(items, 1);
    }
    catch (Exception ignore)
    {
    }
}
 
Example 20
Source File: PaymentFormActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void sendData() {
    if (canceled) {
        return;
    }
    showEditDoneProgress(false, true);
    final TLRPC.TL_payments_sendPaymentForm req = new TLRPC.TL_payments_sendPaymentForm();
    req.msg_id = messageObject.getId();
    if (UserConfig.getInstance(currentAccount).tmpPassword != null && paymentForm.saved_credentials != null) {
        req.credentials = new TLRPC.TL_inputPaymentCredentialsSaved();
        req.credentials.id = paymentForm.saved_credentials.id;
        req.credentials.tmp_password = UserConfig.getInstance(currentAccount).tmpPassword.tmp_password;
    } else if (androidPayCredentials != null) {
        req.credentials = androidPayCredentials;
    } else {
        req.credentials = new TLRPC.TL_inputPaymentCredentials();
        req.credentials.save = saveCardInfo;
        req.credentials.data = new TLRPC.TL_dataJSON();
        req.credentials.data.data = paymentJson;
    }
    if (requestedInfo != null && requestedInfo.id != null) {
        req.requested_info_id = requestedInfo.id;
        req.flags |= 1;
    }
    if (shippingOption != null) {
        req.shipping_option_id = shippingOption.id;
        req.flags |= 2;
    }
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
        if (response != null) {
            if (response instanceof TLRPC.TL_payments_paymentResult) {
                MessagesController.getInstance(currentAccount).processUpdates(((TLRPC.TL_payments_paymentResult) response).updates, false);
                AndroidUtilities.runOnUIThread(this::goToNextStep);
            } else if (response instanceof TLRPC.TL_payments_paymentVerficationNeeded) {
                AndroidUtilities.runOnUIThread(() -> {
                    NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.paymentFinished);
                    setDonePressed(false);
                    webView.setVisibility(View.VISIBLE);
                    webviewLoading = true;
                    showEditDoneProgress(true, true);
                    progressView.setVisibility(View.VISIBLE);
                    doneItem.setEnabled(false);
                    doneItem.getImageView().setVisibility(View.INVISIBLE);
                    webView.loadUrl(((TLRPC.TL_payments_paymentVerficationNeeded) response).url);
                });
            }
        } else {
            AndroidUtilities.runOnUIThread(() -> {
                AlertsCreator.processError(currentAccount, error, PaymentFormActivity.this, req);
                setDonePressed(false);
                showEditDoneProgress(false, false);
            });
        }
    }, ConnectionsManager.RequestFlagFailOnServerErrors);
}