org.telegram.ui.Components.AlertsCreator Java Examples
The following examples show how to use
org.telegram.ui.Components.AlertsCreator.
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: LocationActivity.java From Telegram with GNU General Public License v2.0 | 6 votes |
private void openShareLiveLocation() { if (delegate == null || getParentActivity() == null || myLocation == null) { return; } TLRPC.User user = null; if ((int) dialogId > 0) { user = getMessagesController().getUser((int) dialogId); } showDialog(AlertsCreator.createLocationUpdateDialog(getParentActivity(), user, param -> { TLRPC.TL_messageMediaGeoLive location = new TLRPC.TL_messageMediaGeoLive(); location.geo = new TLRPC.TL_geoPoint(); location.geo.lat = AndroidUtilities.fixLocationCoord(myLocation.getLatitude()); location.geo._long = AndroidUtilities.fixLocationCoord(myLocation.getLongitude()); location.period = param; delegate.didSelectLocation(location, locationType, true, 0); finishFragment(); })); }
Example #2
Source File: ContactsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@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 #3
Source File: LocationActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private void openShareLiveLocation() { if (delegate == null || getParentActivity() == null || myLocation == null) { return; } TLRPC.User user = null; if ((int) dialogId > 0) { user = getMessagesController().getUser((int) dialogId); } showDialog(AlertsCreator.createLocationUpdateDialog(getParentActivity(), user, param -> { TLRPC.TL_messageMediaGeoLive location = new TLRPC.TL_messageMediaGeoLive(); location.geo = new TLRPC.TL_geoPoint(); location.geo.lat = AndroidUtilities.fixLocationCoord(myLocation.getLatitude()); location.geo._long = AndroidUtilities.fixLocationCoord(myLocation.getLongitude()); location.period = param; delegate.didSelectLocation(location, locationType, true, 0); finishFragment(); })); }
Example #4
Source File: DialogOrContactPickerActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private void showBlockAlert(TLRPC.User user) { if (user == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("BlockUser", R.string.BlockUser)); builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("AreYouSureBlockContact2", R.string.AreYouSureBlockContact2, ContactsController.formatName(user.first_name, user.last_name)))); builder.setPositiveButton(LocaleController.getString("BlockContact", R.string.BlockContact), (dialogInterface, i) -> { if (MessagesController.isSupportUser(user)) { AlertsCreator.showSimpleToast(DialogOrContactPickerActivity.this, LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred)); } else { MessagesController.getInstance(currentAccount).blockUser(user.id); AlertsCreator.showSimpleToast(DialogOrContactPickerActivity.this, LocaleController.getString("UserBlocked", R.string.UserBlocked)); } finishFragment(); }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); AlertDialog dialog = builder.create(); showDialog(dialog); TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE); if (button != null) { button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2)); } }
Example #5
Source File: TwoStepVerificationActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private void loadPasswordInfo(final boolean silent) { if (!silent) { loading = true; if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } } TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword(); ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { if (error == null) { loading = false; currentPassword = (TLRPC.TL_account_password) response; if (!canHandleCurrentPassword(currentPassword, false)) { AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true); return; } if (!silent) { passwordEntered = currentPasswordHash != null && currentPasswordHash.length > 0 || !currentPassword.has_password; } initPasswordNewAlgo(currentPassword); NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.didSetOrRemoveTwoStepPassword, currentPassword); } updateRows(); }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin); }
Example #6
Source File: TwoStepVerificationActivity.java From Telegram with GNU General Public License v2.0 | 6 votes |
private void loadPasswordInfo(final boolean silent) { if (!silent) { loading = true; if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } } TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword(); ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { if (error == null) { loading = false; currentPassword = (TLRPC.TL_account_password) response; if (!canHandleCurrentPassword(currentPassword, false)) { AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true); return; } if (!silent) { passwordEntered = currentPasswordHash != null && currentPasswordHash.length > 0 || !currentPassword.has_password; } initPasswordNewAlgo(currentPassword); NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.didSetOrRemoveTwoStepPassword, currentPassword); } updateRows(); }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin); }
Example #7
Source File: ContactsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@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 #8
Source File: DialogOrContactPickerActivity.java From Telegram with GNU General Public License v2.0 | 6 votes |
private void showBlockAlert(TLRPC.User user) { if (user == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("BlockUser", R.string.BlockUser)); builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("AreYouSureBlockContact2", R.string.AreYouSureBlockContact2, ContactsController.formatName(user.first_name, user.last_name)))); builder.setPositiveButton(LocaleController.getString("BlockContact", R.string.BlockContact), (dialogInterface, i) -> { if (MessagesController.isSupportUser(user)) { AlertsCreator.showSimpleToast(DialogOrContactPickerActivity.this, LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred)); } else { MessagesController.getInstance(currentAccount).blockUser(user.id); AlertsCreator.showSimpleToast(DialogOrContactPickerActivity.this, LocaleController.getString("UserBlocked", R.string.UserBlocked)); } finishFragment(); }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); AlertDialog dialog = builder.create(); showDialog(dialog); TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE); if (button != null) { button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2)); } }
Example #9
Source File: ContactsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onResume() { super.onResume(); if (listViewAdapter != null) { listViewAdapter.notifyDataSetChanged(); } if (checkPermission && Build.VERSION.SDK_INT >= 23) { Activity activity = getParentActivity(); if (activity != null) { checkPermission = false; if (activity.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { if (activity.shouldShowRequestPermissionRationale(Manifest.permission.READ_CONTACTS)) { 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(permissionDialog = builder.create()); } else { askForPermissons(true); } } } } }
Example #10
Source File: ContactsActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onResume() { super.onResume(); if (listViewAdapter != null) { listViewAdapter.notifyDataSetChanged(); } if (checkPermission && Build.VERSION.SDK_INT >= 23) { Activity activity = getParentActivity(); if (activity != null) { checkPermission = false; if (activity.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { if (activity.shouldShowRequestPermissionRationale(Manifest.permission.READ_CONTACTS)) { 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(permissionDialog = builder.create()); } else { askForPermissons(true); } } } } }
Example #11
Source File: CancelAccountDeletionActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
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 #12
Source File: CancelAccountDeletionActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
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 #13
Source File: ChangePhoneActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
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 #14
Source File: ChangePhoneActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
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 #15
Source File: CancelAccountDeletionActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
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 #16
Source File: ChangePhoneActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
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 #17
Source File: PeopleNearbyActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void openGroupCreate() { if (!canCreateGroup) { AlertsCreator.showSimpleAlert(PeopleNearbyActivity.this, LocaleController.getString("YourLocatedChannelsTooMuch", R.string.YourLocatedChannelsTooMuch)); return; } groupCreateActivity = new ActionIntroActivity(ActionIntroActivity.ACTION_TYPE_NEARBY_GROUP_CREATE); groupCreateActivity.setGroupCreateAddress(currentGroupCreateAddress, currentGroupCreateDisplayAddress, currentGroupCreateLocation); presentFragment(groupCreateActivity); }
Example #18
Source File: PaymentFormActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void loadPasswordInfo() { if (loadingPasswordInfo) { return; } loadingPasswordInfo = true; TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword(); ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { loadingPasswordInfo = false; if (error == null) { currentPassword = (TLRPC.TL_account_password) response; if (!TwoStepVerificationActivity.canHandleCurrentPassword(currentPassword, false)) { AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true); return; } if (paymentForm != null && currentPassword.has_password) { paymentForm.password_missing = false; paymentForm.can_save_credentials = true; updateSavePaymentField(); } TwoStepVerificationActivity.initPasswordNewAlgo(currentPassword); if (passwordFragment != null) { passwordFragment.setCurrentPassword(currentPassword); } if (!currentPassword.has_password && shortPollRunnable == null) { shortPollRunnable = () -> { if (shortPollRunnable == null) { return; } loadPasswordInfo(); shortPollRunnable = null; }; AndroidUtilities.runOnUIThread(shortPollRunnable, 5000); } } }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin); }
Example #19
Source File: ContactsActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void onResume() { super.onResume(); if (listViewAdapter != null) { listViewAdapter.notifyDataSetChanged(); } if (checkPermission && Build.VERSION.SDK_INT >= 23) { Activity activity = getParentActivity(); if (activity != null) { checkPermission = false; if (activity.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { if (activity.shouldShowRequestPermissionRationale(Manifest.permission.READ_CONTACTS)) { AlertDialog.Builder builder = AlertsCreator.createContactsPermissionDialog(activity, param -> { askAboutContacts = param != 0; if (param == 0) { return; } askForPermissons(false); }); showDialog(permissionDialog = builder.create()); } else { askForPermissons(true); } } } } }
Example #20
Source File: ContactsActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@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 #21
Source File: MediaActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void openUrl(String link) { if (AndroidUtilities.shouldShowUrlInAlert(link)) { AlertsCreator.showOpenUrlAlert(this, link, true, true); } else { Browser.openUrl(getParentActivity(), link); } }
Example #22
Source File: PaymentFormActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void loadPasswordInfo() { if (loadingPasswordInfo) { return; } loadingPasswordInfo = true; TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword(); ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { loadingPasswordInfo = false; if (error == null) { currentPassword = (TLRPC.TL_account_password) response; if (!TwoStepVerificationActivity.canHandleCurrentPassword(currentPassword, false)) { AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true); return; } if (paymentForm != null && currentPassword.has_password) { paymentForm.password_missing = false; paymentForm.can_save_credentials = true; updateSavePaymentField(); } TwoStepVerificationActivity.initPasswordNewAlgo(currentPassword); if (passwordFragment != null) { passwordFragment.setCurrentPassword(currentPassword); } if (!currentPassword.has_password && shortPollRunnable == null) { shortPollRunnable = () -> { if (shortPollRunnable == null) { return; } loadPasswordInfo(); shortPollRunnable = null; }; AndroidUtilities.runOnUIThread(shortPollRunnable, 5000); } } }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin); }
Example #23
Source File: TwoStepVerificationSetupActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void loadPasswordInfo() { TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword(); ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { if (error == null) { currentPassword = (TLRPC.TL_account_password) response; if (!TwoStepVerificationActivity.canHandleCurrentPassword(currentPassword, false)) { AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true); return; } waitingForEmail = !TextUtils.isEmpty(currentPassword.email_unconfirmed_pattern); TwoStepVerificationActivity.initPasswordNewAlgo(currentPassword); if (!paused && closeAfterSet && currentPassword.has_password) { TLRPC.PasswordKdfAlgo pendingCurrentAlgo = currentPassword.current_algo; TLRPC.SecurePasswordKdfAlgo pendingNewSecureAlgo = currentPassword.new_secure_algo; byte[] pendingSecureRandom = currentPassword.secure_random; String pendingEmail = currentPassword.has_recovery ? "1" : null; String pendingHint = currentPassword.hint != null ? currentPassword.hint : ""; if (!waitingForEmail && pendingCurrentAlgo != null) { NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.twoStepPasswordChanged, null, pendingCurrentAlgo, pendingNewSecureAlgo, pendingSecureRandom, pendingEmail, pendingHint, null, null); finishFragment(); } } if (doneAfterPasswordLoad) { needHideProgress(); buttonTextView.callOnClick(); } NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.didSetOrRemoveTwoStepPassword, currentPassword); } }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin); }
Example #24
Source File: ChangePhoneActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
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 #25
Source File: PeopleNearbyActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void openGroupCreate() { if (!canCreateGroup) { AlertsCreator.showSimpleAlert(PeopleNearbyActivity.this, LocaleController.getString("YourLocatedChannelsTooMuch", R.string.YourLocatedChannelsTooMuch)); return; } groupCreateActivity = new ActionIntroActivity(ActionIntroActivity.ACTION_TYPE_NEARBY_GROUP_CREATE); groupCreateActivity.setGroupCreateAddress(currentGroupCreateAddress, currentGroupCreateDisplayAddress, currentGroupCreateLocation); presentFragment(groupCreateActivity); }
Example #26
Source File: MediaActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void openUrl(String link) { if (AndroidUtilities.shouldShowUrlInAlert(link)) { AlertsCreator.showOpenUrlAlert(this, link, true, true); } else { Browser.openUrl(getParentActivity(), link); } }
Example #27
Source File: ContactsActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
@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 #28
Source File: CancelAccountDeletionActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
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 #29
Source File: PaymentFormActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void loadPasswordInfo() { if (loadingPasswordInfo) { return; } loadingPasswordInfo = true; TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword(); ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { loadingPasswordInfo = false; if (error == null) { currentPassword = (TLRPC.TL_account_password) response; if (!TwoStepVerificationActivity.canHandleCurrentPassword(currentPassword, false)) { AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true); return; } if (paymentForm != null && currentPassword.has_password) { paymentForm.password_missing = false; paymentForm.can_save_credentials = true; updateSavePaymentField(); } TwoStepVerificationActivity.initPasswordNewAlgo(currentPassword); if (passwordFragment != null) { passwordFragment.setCurrentPassword(currentPassword); } if (!currentPassword.has_password && shortPollRunnable == null) { shortPollRunnable = () -> { if (shortPollRunnable == null) { return; } loadPasswordInfo(); shortPollRunnable = null; }; AndroidUtilities.runOnUIThread(shortPollRunnable, 5000); } } }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin); }
Example #30
Source File: TwoStepVerificationSetupActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void loadPasswordInfo() { TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword(); ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { if (error == null) { currentPassword = (TLRPC.TL_account_password) response; if (!TwoStepVerificationActivity.canHandleCurrentPassword(currentPassword, false)) { AlertsCreator.showUpdateAppAlert(getParentActivity(), LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true); return; } waitingForEmail = !TextUtils.isEmpty(currentPassword.email_unconfirmed_pattern); TwoStepVerificationActivity.initPasswordNewAlgo(currentPassword); if (!paused && closeAfterSet && currentPassword.has_password) { TLRPC.PasswordKdfAlgo pendingCurrentAlgo = currentPassword.current_algo; TLRPC.SecurePasswordKdfAlgo pendingNewSecureAlgo = currentPassword.new_secure_algo; byte[] pendingSecureRandom = currentPassword.secure_random; String pendingEmail = currentPassword.has_recovery ? "1" : null; String pendingHint = currentPassword.hint != null ? currentPassword.hint : ""; if (!waitingForEmail && pendingCurrentAlgo != null) { NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.twoStepPasswordChanged, null, pendingCurrentAlgo, pendingNewSecureAlgo, pendingSecureRandom, pendingEmail, pendingHint, null, null); finishFragment(); } } if (doneAfterPasswordLoad) { needHideProgress(); buttonTextView.callOnClick(); } NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.didSetOrRemoveTwoStepPassword, currentPassword); } }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin); }