Java Code Examples for org.telegram.messenger.AndroidUtilities#setWaitingForSms()
The following examples show how to use
org.telegram.messenger.AndroidUtilities#setWaitingForSms() .
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: LoginActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void onDestroyActivity() { super.onDestroyActivity(); if (currentType == 2) { AndroidUtilities.setWaitingForSms(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall); } waitingForEvent = false; destroyTimer(); destroyCodeTimer(); }
Example 2
Source File: LoginActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void onBackPressed() { destroyTimer(); destroyCodeTimer(); currentParams = null; if (currentType == 2) { AndroidUtilities.setWaitingForSms(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall); } waitingForEvent = false; }
Example 3
Source File: LoginActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void onDestroyActivity() { super.onDestroyActivity(); if (currentType == 2) { AndroidUtilities.setWaitingForSms(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall); } waitingForEvent = false; destroyTimer(); destroyCodeTimer(); }
Example 4
Source File: CancelAccountDeletionActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void onDestroyActivity() { super.onDestroyActivity(); if (currentType == 2) { AndroidUtilities.setWaitingForSms(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall); } waitingForEvent = false; destroyTimer(); destroyCodeTimer(); }
Example 5
Source File: ChangePhoneActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public boolean onBackPressed(boolean force) { if (!force) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setMessage(LocaleController.getString("StopVerification", R.string.StopVerification)); builder.setPositiveButton(LocaleController.getString("Continue", R.string.Continue), null); builder.setNegativeButton(LocaleController.getString("Stop", R.string.Stop), (dialogInterface, i) -> { onBackPressed(true); setPage(0, true, null, true); }); showDialog(builder.create()); return false; } TLRPC.TL_auth_cancelCode req = new TLRPC.TL_auth_cancelCode(); req.phone_number = requestPhone; req.phone_code_hash = phoneHash; ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> { }, ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin); destroyTimer(); destroyCodeTimer(); currentParams = null; if (currentType == 2) { AndroidUtilities.setWaitingForSms(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall); } waitingForEvent = false; return true; }
Example 6
Source File: ChangePhoneActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void onDestroyActivity() { super.onDestroyActivity(); if (currentType == 2) { AndroidUtilities.setWaitingForSms(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall); } waitingForEvent = false; destroyTimer(); destroyCodeTimer(); }
Example 7
Source File: CancelAccountDeletionActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onDestroyActivity() { super.onDestroyActivity(); if (currentType == 2) { AndroidUtilities.setWaitingForSms(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall); } waitingForEvent = false; destroyTimer(); destroyCodeTimer(); }
Example 8
Source File: ChangePhoneActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onDestroyActivity() { super.onDestroyActivity(); if (currentType == 2) { AndroidUtilities.setWaitingForSms(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall); } waitingForEvent = false; destroyTimer(); destroyCodeTimer(); }
Example 9
Source File: ChangePhoneActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void onDestroyActivity() { super.onDestroyActivity(); if (currentType == 2) { AndroidUtilities.setWaitingForSms(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall); } waitingForEvent = false; destroyTimer(); destroyCodeTimer(); }
Example 10
Source File: CancelAccountDeletionActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onDestroyActivity() { super.onDestroyActivity(); if (currentType == 2) { AndroidUtilities.setWaitingForSms(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall); } waitingForEvent = false; destroyTimer(); destroyCodeTimer(); }
Example 11
Source File: ChangePhoneActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onBackPressed() { destroyTimer(); destroyCodeTimer(); currentParams = null; if (currentType == 2) { AndroidUtilities.setWaitingForSms(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall); } waitingForEvent = false; }
Example 12
Source File: ChangePhoneActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public void setParams(Bundle params, boolean restore) { if (params == null) { return; } codeField.setText(""); waitingForEvent = true; if (currentType == 2) { AndroidUtilities.setWaitingForSms(true); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(true); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didReceiveCall); } currentParams = params; phone = params.getString("phone"); emailPhone = params.getString("ephone"); requestPhone = params.getString("phoneFormated"); phoneHash = params.getString("phoneHash"); timeout = time = params.getInt("timeout"); openTime = (int) (System.currentTimeMillis() / 1000); nextType = params.getInt("nextType"); pattern = params.getString("pattern"); length = params.getInt("length"); if (length != 0) { InputFilter[] inputFilters = new InputFilter[1]; inputFilters[0] = new InputFilter.LengthFilter(length); codeField.setFilters(inputFilters); } else { codeField.setFilters(new InputFilter[0]); } if (progressView != null) { progressView.setVisibility(nextType != 0 ? VISIBLE : GONE); } if (phone == null) { return; } String number = PhoneFormat.getInstance().format(phone); CharSequence str = ""; if (currentType == 1) { str = AndroidUtilities.replaceTags(LocaleController.getString("SentAppCode", R.string.SentAppCode)); } else if (currentType == 2) { str = AndroidUtilities.replaceTags(LocaleController.formatString("SentSmsCode", R.string.SentSmsCode, LocaleController.addNbsp(number))); } else if (currentType == 3) { str = AndroidUtilities.replaceTags(LocaleController.formatString("SentCallCode", R.string.SentCallCode, LocaleController.addNbsp(number))); } else if (currentType == 4) { str = AndroidUtilities.replaceTags(LocaleController.formatString("SentCallOnly", R.string.SentCallOnly, LocaleController.addNbsp(number))); } confirmTextView.setText(str); if (currentType != 3) { AndroidUtilities.showKeyboard(codeField); codeField.requestFocus(); } else { AndroidUtilities.hideKeyboard(codeField); } destroyTimer(); destroyCodeTimer(); lastCurrentTime = System.currentTimeMillis(); if (currentType == 1) { problemText.setVisibility(VISIBLE); timeText.setVisibility(GONE); } else if (currentType == 3 && (nextType == 4 || nextType == 2)) { problemText.setVisibility(GONE); timeText.setVisibility(VISIBLE); if (nextType == 4) { timeText.setText(LocaleController.formatString("CallText", R.string.CallText, 1, 0)); } else if (nextType == 2) { timeText.setText(LocaleController.formatString("SmsText", R.string.SmsText, 1, 0)); } createTimer(); } else if (currentType == 2 && (nextType == 4 || nextType == 3)) { timeText.setVisibility(VISIBLE); timeText.setText(LocaleController.formatString("CallText", R.string.CallText, 2, 0)); problemText.setVisibility(time < 1000 ? VISIBLE : GONE); createTimer(); } else { timeText.setVisibility(GONE); problemText.setVisibility(GONE); createCodeTimer(); } }
Example 13
Source File: CancelAccountDeletionActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override public void onNextPressed() { if (nextPressed) { return; } String code = getCode(); if (TextUtils.isEmpty(code)) { AndroidUtilities.shakeView(codeFieldContainer, 2, 0); return; } nextPressed = true; if (currentType == 2) { AndroidUtilities.setWaitingForSms(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall); } waitingForEvent = false; final TLRPC.TL_account_confirmPhone req = new TLRPC.TL_account_confirmPhone(); req.phone_code = code; req.phone_code_hash = phoneHash; destroyTimer(); needShowProgress(); ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { needHideProgress(); nextPressed = false; if (error == null) { errorDialog = AlertsCreator.showSimpleAlert(CancelAccountDeletionActivity.this, LocaleController.formatString("CancelLinkSuccess", R.string.CancelLinkSuccess, PhoneFormat.getInstance().format("+" + phone))); } else { lastError = error.text; if (currentType == 3 && (nextType == 4 || nextType == 2) || currentType == 2 && (nextType == 4 || nextType == 3) || currentType == 4 && nextType == 2) { createTimer(); } if (currentType == 2) { AndroidUtilities.setWaitingForSms(true); NotificationCenter.getGlobalInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(true); NotificationCenter.getGlobalInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveCall); } waitingForEvent = true; if (currentType != 3) { AlertsCreator.processError(currentAccount, error, CancelAccountDeletionActivity.this, req); } if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) { for (int a = 0; a < codeField.length; a++) { codeField[a].setText(""); } codeField[0].requestFocus(); } else if (error.text.contains("PHONE_CODE_EXPIRED")) { onBackPressed(true); setPage(0, true, null, true); } } }), ConnectionsManager.RequestFlagFailOnServerErrors); }
Example 14
Source File: CancelAccountDeletionActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public void onNextPressed() { if (nextPressed) { return; } nextPressed = true; if (currentType == 2) { AndroidUtilities.setWaitingForSms(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall); } waitingForEvent = false; final TLRPC.TL_account_confirmPhone req = new TLRPC.TL_account_confirmPhone(); req.phone_code = codeField.getText().toString(); req.phone_code_hash = phoneHash; destroyTimer(); needShowProgress(); 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() { needHideProgress(); nextPressed = false; if (error == null) { errorDialog = AlertsCreator.showSimpleAlert(CancelAccountDeletionActivity.this, LocaleController.formatString("CancelLinkSuccess", R.string.CancelLinkSuccess, PhoneFormat.getInstance().format("+" + phone))); } else { lastError = error.text; if (currentType == 3 && (nextType == 4 || nextType == 2) || currentType == 2 && (nextType == 4 || nextType == 3)) { createTimer(); } if (currentType == 2) { AndroidUtilities.setWaitingForSms(true); NotificationCenter.getGlobalInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(true); NotificationCenter.getGlobalInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveCall); } waitingForEvent = true; if (currentType != 3) { AlertsCreator.processError(currentAccount, error, CancelAccountDeletionActivity.this, req); } } } }); } }, ConnectionsManager.RequestFlagFailOnServerErrors); }
Example 15
Source File: CancelAccountDeletionActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public void setParams(Bundle params, boolean restore) { if (params == null) { return; } codeField.setText(""); waitingForEvent = true; if (currentType == 2) { AndroidUtilities.setWaitingForSms(true); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(true); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didReceiveCall); } currentParams = params; phone = params.getString("phone"); phoneHash = params.getString("phoneHash"); timeout = time = params.getInt("timeout"); openTime = (int) (System.currentTimeMillis() / 1000); nextType = params.getInt("nextType"); pattern = params.getString("pattern"); length = params.getInt("length"); if (length != 0) { InputFilter[] inputFilters = new InputFilter[1]; inputFilters[0] = new InputFilter.LengthFilter(length); codeField.setFilters(inputFilters); } else { codeField.setFilters(new InputFilter[0]); } if (progressView != null) { progressView.setVisibility(nextType != 0 ? VISIBLE : GONE); } if (phone == null) { return; } String number = PhoneFormat.getInstance().format(phone); CharSequence str; /*if (currentType == 1) { str = AndroidUtilities.replaceTags(LocaleController.getString("SentAppCode", R.string.SentAppCode)); } else if (currentType == 2) {*/ str = AndroidUtilities.replaceTags(LocaleController.formatString("CancelAccountResetInfo", R.string.CancelAccountResetInfo, PhoneFormat.getInstance().format("+" + number))); /*} else if (currentType == 3) { str = AndroidUtilities.replaceTags(LocaleController.formatString("SentCallCode", R.string.SentCallCode, number)); } else if (currentType == 4) { str = AndroidUtilities.replaceTags(LocaleController.formatString("SentCallOnly", R.string.SentCallOnly, number)); }*/ confirmTextView.setText(str); if (currentType != 3) { AndroidUtilities.showKeyboard(codeField); codeField.requestFocus(); } else { AndroidUtilities.hideKeyboard(codeField); } destroyTimer(); destroyCodeTimer(); lastCurrentTime = System.currentTimeMillis(); if (currentType == 1) { problemText.setVisibility(VISIBLE); timeText.setVisibility(GONE); } else if (currentType == 3 && (nextType == 4 || nextType == 2)) { problemText.setVisibility(GONE); timeText.setVisibility(VISIBLE); if (nextType == 4) { timeText.setText(LocaleController.formatString("CallText", R.string.CallText, 1, 0)); } else if (nextType == 2) { timeText.setText(LocaleController.formatString("SmsText", R.string.SmsText, 1, 0)); } createTimer(); } else if (currentType == 2 && (nextType == 4 || nextType == 3)) { timeText.setVisibility(VISIBLE); timeText.setText(LocaleController.formatString("CallText", R.string.CallText, 2, 0)); problemText.setVisibility(time < 1000 ? VISIBLE : GONE); createTimer(); } else { timeText.setVisibility(GONE); problemText.setVisibility(GONE); createCodeTimer(); } }
Example 16
Source File: CancelAccountDeletionActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public void onNextPressed() { if (nextPressed) { return; } nextPressed = true; if (currentType == 2) { AndroidUtilities.setWaitingForSms(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall); } waitingForEvent = false; final TLRPC.TL_account_confirmPhone req = new TLRPC.TL_account_confirmPhone(); req.phone_code = codeField.getText().toString(); req.phone_code_hash = phoneHash; destroyTimer(); needShowProgress(); 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() { needHideProgress(); nextPressed = false; if (error == null) { errorDialog = AlertsCreator.showSimpleAlert(CancelAccountDeletionActivity.this, LocaleController.formatString("CancelLinkSuccess", R.string.CancelLinkSuccess, PhoneFormat.getInstance().format("+" + phone))); } else { lastError = error.text; if (currentType == 3 && (nextType == 4 || nextType == 2) || currentType == 2 && (nextType == 4 || nextType == 3)) { createTimer(); } if (currentType == 2) { AndroidUtilities.setWaitingForSms(true); NotificationCenter.getGlobalInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(true); NotificationCenter.getGlobalInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveCall); } waitingForEvent = true; if (currentType != 3) { AlertsCreator.processError(currentAccount, error, CancelAccountDeletionActivity.this, req); } } } }); } }, ConnectionsManager.RequestFlagFailOnServerErrors); }
Example 17
Source File: CancelAccountDeletionActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public void setParams(Bundle params, boolean restore) { if (params == null) { return; } codeField.setText(""); waitingForEvent = true; if (currentType == 2) { AndroidUtilities.setWaitingForSms(true); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(true); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didReceiveCall); } currentParams = params; phone = params.getString("phone"); phoneHash = params.getString("phoneHash"); timeout = time = params.getInt("timeout"); openTime = (int) (System.currentTimeMillis() / 1000); nextType = params.getInt("nextType"); pattern = params.getString("pattern"); length = params.getInt("length"); if (length != 0) { InputFilter[] inputFilters = new InputFilter[1]; inputFilters[0] = new InputFilter.LengthFilter(length); codeField.setFilters(inputFilters); } else { codeField.setFilters(new InputFilter[0]); } if (progressView != null) { progressView.setVisibility(nextType != 0 ? VISIBLE : GONE); } if (phone == null) { return; } String number = PhoneFormat.getInstance().format(phone); CharSequence str; /*if (currentType == 1) { str = AndroidUtilities.replaceTags(LocaleController.getString("SentAppCode", R.string.SentAppCode)); } else if (currentType == 2) {*/ str = AndroidUtilities.replaceTags(LocaleController.formatString("CancelAccountResetInfo", R.string.CancelAccountResetInfo, PhoneFormat.getInstance().format("+" + number))); /*} else if (currentType == 3) { str = AndroidUtilities.replaceTags(LocaleController.formatString("SentCallCode", R.string.SentCallCode, number)); } else if (currentType == 4) { str = AndroidUtilities.replaceTags(LocaleController.formatString("SentCallOnly", R.string.SentCallOnly, number)); }*/ confirmTextView.setText(str); if (currentType != 3) { AndroidUtilities.showKeyboard(codeField); codeField.requestFocus(); } else { AndroidUtilities.hideKeyboard(codeField); } destroyTimer(); destroyCodeTimer(); lastCurrentTime = System.currentTimeMillis(); if (currentType == 1) { problemText.setVisibility(VISIBLE); timeText.setVisibility(GONE); } else if (currentType == 3 && (nextType == 4 || nextType == 2)) { problemText.setVisibility(GONE); timeText.setVisibility(VISIBLE); if (nextType == 4) { timeText.setText(LocaleController.formatString("CallText", R.string.CallText, 1, 0)); } else if (nextType == 2) { timeText.setText(LocaleController.formatString("SmsText", R.string.SmsText, 1, 0)); } createTimer(); } else if (currentType == 2 && (nextType == 4 || nextType == 3)) { timeText.setVisibility(VISIBLE); timeText.setText(LocaleController.formatString("CallText", R.string.CallText, 2, 0)); problemText.setVisibility(time < 1000 ? VISIBLE : GONE); createTimer(); } else { timeText.setVisibility(GONE); problemText.setVisibility(GONE); createCodeTimer(); } }
Example 18
Source File: CancelAccountDeletionActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@Override public void onNextPressed() { if (nextPressed) { return; } String code = getCode(); if (TextUtils.isEmpty(code)) { AndroidUtilities.shakeView(codeFieldContainer, 2, 0); return; } nextPressed = true; if (currentType == 2) { AndroidUtilities.setWaitingForSms(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall); } waitingForEvent = false; final TLRPC.TL_account_confirmPhone req = new TLRPC.TL_account_confirmPhone(); req.phone_code = code; req.phone_code_hash = phoneHash; destroyTimer(); needShowProgress(); ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { needHideProgress(); nextPressed = false; if (error == null) { errorDialog = AlertsCreator.showSimpleAlert(CancelAccountDeletionActivity.this, LocaleController.formatString("CancelLinkSuccess", R.string.CancelLinkSuccess, PhoneFormat.getInstance().format("+" + phone))); } else { lastError = error.text; if (currentType == 3 && (nextType == 4 || nextType == 2) || currentType == 2 && (nextType == 4 || nextType == 3) || currentType == 4 && nextType == 2) { createTimer(); } if (currentType == 2) { AndroidUtilities.setWaitingForSms(true); NotificationCenter.getGlobalInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(true); NotificationCenter.getGlobalInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveCall); } waitingForEvent = true; if (currentType != 3) { AlertsCreator.processError(currentAccount, error, CancelAccountDeletionActivity.this, req); } if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) { for (int a = 0; a < codeField.length; a++) { codeField[a].setText(""); } codeField[0].requestFocus(); } else if (error.text.contains("PHONE_CODE_EXPIRED")) { onBackPressed(true); setPage(0, true, null, true); } } }), ConnectionsManager.RequestFlagFailOnServerErrors); }
Example 19
Source File: ChangePhoneActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override public void onNextPressed() { if (nextPressed) { return; } String code = getCode(); if (TextUtils.isEmpty(code)) { AndroidUtilities.shakeView(codeFieldContainer, 2, 0); return; } nextPressed = true; if (currentType == 2) { AndroidUtilities.setWaitingForSms(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(false); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall); } waitingForEvent = false; final TLRPC.TL_account_changePhone req = new TLRPC.TL_account_changePhone(); req.phone_number = requestPhone; req.phone_code = code; req.phone_code_hash = phoneHash; destroyTimer(); needShowProgress(); ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { needHideProgress(); nextPressed = false; if (error == null) { TLRPC.User user = (TLRPC.User) response; destroyTimer(); destroyCodeTimer(); UserConfig.getInstance(currentAccount).setCurrentUser(user); UserConfig.getInstance(currentAccount).saveConfig(true); ArrayList<TLRPC.User> users = new ArrayList<>(); users.add(user); MessagesStorage.getInstance(currentAccount).putUsersAndChats(users, null, true, true); MessagesController.getInstance(currentAccount).putUser(user, false); finishFragment(); NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.mainUserInfoChanged); } else { lastError = error.text; if (currentType == 3 && (nextType == 4 || nextType == 2) || currentType == 2 && (nextType == 4 || nextType == 3) || currentType == 4 && nextType == 2) { createTimer(); } if (currentType == 2) { AndroidUtilities.setWaitingForSms(true); NotificationCenter.getGlobalInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(true); NotificationCenter.getGlobalInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveCall); } waitingForEvent = true; if (currentType != 3) { AlertsCreator.processError(currentAccount, error, ChangePhoneActivity.this, req); } if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) { for (int a = 0; a < codeField.length; a++) { codeField[a].setText(""); } codeField[0].requestFocus(); } else if (error.text.contains("PHONE_CODE_EXPIRED")) { onBackPressed(true); setPage(0, true, null, true); } } }), ConnectionsManager.RequestFlagFailOnServerErrors); }
Example 20
Source File: ChangePhoneActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public void setParams(Bundle params, boolean restore) { if (params == null) { return; } codeField.setText(""); waitingForEvent = true; if (currentType == 2) { AndroidUtilities.setWaitingForSms(true); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didReceiveSmsCode); } else if (currentType == 3) { AndroidUtilities.setWaitingForCall(true); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didReceiveCall); } currentParams = params; phone = params.getString("phone"); emailPhone = params.getString("ephone"); requestPhone = params.getString("phoneFormated"); phoneHash = params.getString("phoneHash"); timeout = time = params.getInt("timeout"); openTime = (int) (System.currentTimeMillis() / 1000); nextType = params.getInt("nextType"); pattern = params.getString("pattern"); length = params.getInt("length"); if (length != 0) { InputFilter[] inputFilters = new InputFilter[1]; inputFilters[0] = new InputFilter.LengthFilter(length); codeField.setFilters(inputFilters); } else { codeField.setFilters(new InputFilter[0]); } if (progressView != null) { progressView.setVisibility(nextType != 0 ? VISIBLE : GONE); } if (phone == null) { return; } String number = PhoneFormat.getInstance().format(phone); CharSequence str = ""; if (currentType == 1) { str = AndroidUtilities.replaceTags(LocaleController.getString("SentAppCode", R.string.SentAppCode)); } else if (currentType == 2) { str = AndroidUtilities.replaceTags(LocaleController.formatString("SentSmsCode", R.string.SentSmsCode, LocaleController.addNbsp(number))); } else if (currentType == 3) { str = AndroidUtilities.replaceTags(LocaleController.formatString("SentCallCode", R.string.SentCallCode, LocaleController.addNbsp(number))); } else if (currentType == 4) { str = AndroidUtilities.replaceTags(LocaleController.formatString("SentCallOnly", R.string.SentCallOnly, LocaleController.addNbsp(number))); } confirmTextView.setText(str); if (currentType != 3) { AndroidUtilities.showKeyboard(codeField); codeField.requestFocus(); } else { AndroidUtilities.hideKeyboard(codeField); } destroyTimer(); destroyCodeTimer(); lastCurrentTime = System.currentTimeMillis(); if (currentType == 1) { problemText.setVisibility(VISIBLE); timeText.setVisibility(GONE); } else if (currentType == 3 && (nextType == 4 || nextType == 2)) { problemText.setVisibility(GONE); timeText.setVisibility(VISIBLE); if (nextType == 4) { timeText.setText(LocaleController.formatString("CallText", R.string.CallText, 1, 0)); } else if (nextType == 2) { timeText.setText(LocaleController.formatString("SmsText", R.string.SmsText, 1, 0)); } createTimer(); } else if (currentType == 2 && (nextType == 4 || nextType == 3)) { timeText.setVisibility(VISIBLE); timeText.setText(LocaleController.formatString("CallText", R.string.CallText, 2, 0)); problemText.setVisibility(time < 1000 ? VISIBLE : GONE); createTimer(); } else { timeText.setVisibility(GONE); problemText.setVisibility(GONE); createCodeTimer(); } }