Java Code Examples for org.telegram.tgnet.TLRPC#TL_auth_resendCode

The following examples show how to use org.telegram.tgnet.TLRPC#TL_auth_resendCode . 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: ChangePhoneActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void resendCode() {
    final Bundle params = new Bundle();
    params.putString("phone", phone);
    params.putString("ephone", emailPhone);
    params.putString("phoneFormated", requestPhone);

    nextPressed = true;
    needShowProgress();

    final TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode();
    req.phone_number = requestPhone;
    req.phone_code_hash = phoneHash;
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {
        @Override
        public void run(final TLObject response, final TLRPC.TL_error error) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public void run() {
                    nextPressed = false;
                    if (error == null) {
                        fillNextCodeParams(params, (TLRPC.TL_auth_sentCode) response);
                    } else {
                        AlertsCreator.processError(currentAccount, error, ChangePhoneActivity.this, req);
                        if (error.text.contains("PHONE_CODE_EXPIRED")) {
                            onBackPressed();
                            setPage(0, true, null, true);
                        }
                    }
                    needHideProgress();
                }
            });
        }
    }, ConnectionsManager.RequestFlagFailOnServerErrors);
}
 
Example 2
Source File: CancelAccountDeletionActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void resendCode() {
    final Bundle params = new Bundle();
    params.putString("phone", phone);

    nextPressed = true;
    needShowProgress();

    final TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode();
    req.phone_number = phone;
    req.phone_code_hash = phoneHash;
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {
        @Override
        public void run(final TLObject response, final TLRPC.TL_error error) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public void run() {
                    nextPressed = false;
                    if (error == null) {
                        fillNextCodeParams(params, (TLRPC.TL_auth_sentCode) response);
                    } else {
                        AlertsCreator.processError(currentAccount, error, CancelAccountDeletionActivity.this, req);
                    }
                    needHideProgress();
                }
            });
        }
    }, ConnectionsManager.RequestFlagFailOnServerErrors);
}
 
Example 3
Source File: ChangePhoneActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void resendCode() {
    final Bundle params = new Bundle();
    params.putString("phone", phone);
    params.putString("ephone", emailPhone);
    params.putString("phoneFormated", requestPhone);

    nextPressed = true;
    needShowProgress();

    final TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode();
    req.phone_number = requestPhone;
    req.phone_code_hash = phoneHash;
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {
        @Override
        public void run(final TLObject response, final TLRPC.TL_error error) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public void run() {
                    nextPressed = false;
                    if (error == null) {
                        fillNextCodeParams(params, (TLRPC.TL_auth_sentCode) response);
                    } else {
                        AlertsCreator.processError(currentAccount, error, ChangePhoneActivity.this, req);
                        if (error.text.contains("PHONE_CODE_EXPIRED")) {
                            onBackPressed();
                            setPage(0, true, null, true);
                        }
                    }
                    needHideProgress();
                }
            });
        }
    }, ConnectionsManager.RequestFlagFailOnServerErrors);
}
 
Example 4
Source File: CancelAccountDeletionActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void resendCode() {
    final Bundle params = new Bundle();
    params.putString("phone", phone);

    nextPressed = true;
    needShowProgress();

    final TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode();
    req.phone_number = phone;
    req.phone_code_hash = phoneHash;
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() {
        @Override
        public void run(final TLObject response, final TLRPC.TL_error error) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public void run() {
                    nextPressed = false;
                    if (error == null) {
                        fillNextCodeParams(params, (TLRPC.TL_auth_sentCode) response);
                    } else {
                        AlertsCreator.processError(currentAccount, error, CancelAccountDeletionActivity.this, req);
                    }
                    needHideProgress();
                }
            });
        }
    }, ConnectionsManager.RequestFlagFailOnServerErrors);
}
 
Example 5
Source File: ChangePhoneActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void resendCode() {
    final Bundle params = new Bundle();
    params.putString("phone", phone);
    params.putString("ephone", emailPhone);
    params.putString("phoneFormated", requestPhone);

    nextPressed = true;
    needShowProgress();

    final TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode();
    req.phone_number = requestPhone;
    req.phone_code_hash = phoneHash;
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        nextPressed = false;
        if (error == null) {
            fillNextCodeParams(params, (TLRPC.TL_auth_sentCode) response);
        } else {
            AlertDialog dialog = (AlertDialog) AlertsCreator.processError(currentAccount, error, ChangePhoneActivity.this, req);
            if (dialog != null && error.text.contains("PHONE_CODE_EXPIRED")) {
                dialog.setPositiveButtonListener((dialog1, which) -> {
                    onBackPressed(true);
                    finishFragment();
                });
            }
        }
        needHideProgress();
    }), ConnectionsManager.RequestFlagFailOnServerErrors);
}
 
Example 6
Source File: CancelAccountDeletionActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void resendCode() {
    final Bundle params = new Bundle();
    params.putString("phone", phone);

    nextPressed = true;
    needShowProgress();

    final TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode();
    req.phone_number = phone;
    req.phone_code_hash = phoneHash;
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        nextPressed = false;
        if (error == null) {
            fillNextCodeParams(params, (TLRPC.TL_auth_sentCode) response);
        } else {
            if (error.text != null) {
                AlertDialog dialog = (AlertDialog) AlertsCreator.processError(currentAccount, error, CancelAccountDeletionActivity.this, req);
                if (dialog != null && error.text.contains("PHONE_CODE_EXPIRED")) {
                    dialog.setPositiveButtonListener((dialog1, which) -> {
                        onBackPressed(true);
                        finishFragment();
                    });
                }
            }
        }
        needHideProgress();
    }), ConnectionsManager.RequestFlagFailOnServerErrors);
}
 
Example 7
Source File: ChangePhoneActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void resendCode() {
    final Bundle params = new Bundle();
    params.putString("phone", phone);
    params.putString("ephone", emailPhone);
    params.putString("phoneFormated", requestPhone);

    nextPressed = true;
    needShowProgress();

    final TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode();
    req.phone_number = requestPhone;
    req.phone_code_hash = phoneHash;
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        nextPressed = false;
        if (error == null) {
            fillNextCodeParams(params, (TLRPC.TL_auth_sentCode) response);
        } else {
            AlertDialog dialog = (AlertDialog) AlertsCreator.processError(currentAccount, error, ChangePhoneActivity.this, req);
            if (dialog != null && error.text.contains("PHONE_CODE_EXPIRED")) {
                dialog.setPositiveButtonListener((dialog1, which) -> {
                    onBackPressed(true);
                    finishFragment();
                });
            }
        }
        needHideProgress();
    }), ConnectionsManager.RequestFlagFailOnServerErrors);
}
 
Example 8
Source File: CancelAccountDeletionActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void resendCode() {
    final Bundle params = new Bundle();
    params.putString("phone", phone);

    nextPressed = true;
    needShowProgress();

    final TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode();
    req.phone_number = phone;
    req.phone_code_hash = phoneHash;
    ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
        nextPressed = false;
        if (error == null) {
            fillNextCodeParams(params, (TLRPC.TL_auth_sentCode) response);
        } else {
            if (error.text != null) {
                AlertDialog dialog = (AlertDialog) AlertsCreator.processError(currentAccount, error, CancelAccountDeletionActivity.this, req);
                if (dialog != null && error.text.contains("PHONE_CODE_EXPIRED")) {
                    dialog.setPositiveButtonListener((dialog1, which) -> {
                        onBackPressed(true);
                        finishFragment();
                    });
                }
            }
        }
        needHideProgress();
    }), ConnectionsManager.RequestFlagFailOnServerErrors);
}
 
Example 9
Source File: LoginActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void resendCode()
{
    final Bundle params = new Bundle();
    params.putString("phone", phone);
    params.putString("ephone", emailPhone);
    params.putString("phoneFormated", requestPhone);

    nextPressed = true;

    TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode();
    req.phone_number = requestPhone;
    req.phone_code_hash = phoneHash;
    int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() ->
    {
        nextPressed = false;
        if (error == null)
        {
            fillNextCodeParams(params, (TLRPC.TL_auth_sentCode) response);
        }
        else
        {
            if (error.text != null)
            {
                if (error.text.contains("PHONE_NUMBER_INVALID"))
                {
                    needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber));
                }
                else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID"))
                {
                    needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("InvalidCode", R.string.InvalidCode));
                }
                else if (error.text.contains("PHONE_CODE_EXPIRED"))
                {
                    onBackPressed();
                    setPage(0, true, null, true);
                    needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("CodeExpired", R.string.CodeExpired));
                }
                else if (error.text.startsWith("FLOOD_WAIT"))
                {
                    needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("FloodWait", R.string.FloodWait));
                }
                else if (error.code != -1000)
                {
                    needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred) + "\n" + error.text);
                }
            }
        }
        needHideProgress();
    }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin);
    needShowProgress(0);
}
 
Example 10
Source File: LoginActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void resendCode()
{
    final Bundle params = new Bundle();
    params.putString("phone", phone);
    params.putString("ephone", emailPhone);
    params.putString("phoneFormated", requestPhone);

    nextPressed = true;

    TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode();
    req.phone_number = requestPhone;
    req.phone_code_hash = phoneHash;
    int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() ->
    {
        nextPressed = false;
        if (error == null)
        {
            fillNextCodeParams(params, (TLRPC.TL_auth_sentCode) response);
        }
        else
        {
            if (error.text != null)
            {
                if (error.text.contains("PHONE_NUMBER_INVALID"))
                {
                    needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber));
                }
                else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID"))
                {
                    needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("InvalidCode", R.string.InvalidCode));
                }
                else if (error.text.contains("PHONE_CODE_EXPIRED"))
                {
                    onBackPressed();
                    setPage(0, true, null, true);
                    needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("CodeExpired", R.string.CodeExpired));
                }
                else if (error.text.startsWith("FLOOD_WAIT"))
                {
                    needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("FloodWait", R.string.FloodWait));
                }
                else if (error.code != -1000)
                {
                    needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred) + "\n" + error.text);
                }
            }
        }
        needHideProgress();
    }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin);
    needShowProgress(0);
}