use of org.telegram.ui.ActionBar.AlertDialog in project Telegram-FOSS by Telegram-FOSS-Team.
the class LinkEditActivity method onCreateClicked.
private void onCreateClicked(View view) {
if (loading) {
return;
}
int timeIndex = timeChooseView.getSelectedIndex();
if (timeIndex < dispalyedDates.size() && dispalyedDates.get(timeIndex) < 0) {
AndroidUtilities.shakeView(timeEditText, 2, 0);
Vibrator vibrator = (Vibrator) timeEditText.getContext().getSystemService(Context.VIBRATOR_SERVICE);
if (vibrator != null) {
vibrator.vibrate(200);
}
return;
}
if (type == CREATE_TYPE) {
if (progressDialog != null) {
progressDialog.dismiss();
}
loading = true;
progressDialog = new AlertDialog(getParentActivity(), 3);
progressDialog.showDelayed(500);
TLRPC.TL_messages_exportChatInvite req = new TLRPC.TL_messages_exportChatInvite();
req.peer = getMessagesController().getInputPeer(-chatId);
req.legacy_revoke_permanent = false;
int i = timeChooseView.getSelectedIndex();
req.flags |= 1;
if (i < dispalyedDates.size()) {
req.expire_date = dispalyedDates.get(i) + getConnectionsManager().getCurrentTime();
} else {
req.expire_date = 0;
}
i = usesChooseView.getSelectedIndex();
req.flags |= 2;
if (i < dispalyedUses.size()) {
req.usage_limit = dispalyedUses.get(i);
} else {
req.usage_limit = 0;
}
req.request_needed = approveCell.isChecked();
if (req.request_needed) {
req.usage_limit = 0;
}
req.title = nameEditText.getText().toString();
if (!TextUtils.isEmpty(req.title)) {
req.flags |= 16;
}
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
loading = false;
if (progressDialog != null) {
progressDialog.dismiss();
}
if (error == null) {
if (callback != null) {
callback.onLinkCreated(response);
}
finishFragment();
} else {
AlertsCreator.showSimpleAlert(LinkEditActivity.this, error.text);
}
}));
} else if (type == EDIT_TYPE) {
if (progressDialog != null) {
progressDialog.dismiss();
}
TLRPC.TL_messages_editExportedChatInvite req = new TLRPC.TL_messages_editExportedChatInvite();
req.link = inviteToEdit.link;
req.revoked = false;
req.peer = getMessagesController().getInputPeer(-chatId);
boolean edited = false;
int i = timeChooseView.getSelectedIndex();
if (i < dispalyedDates.size()) {
if (currentInviteDate != dispalyedDates.get(i)) {
req.flags |= 1;
req.expire_date = dispalyedDates.get(i) + getConnectionsManager().getCurrentTime();
edited = true;
}
} else {
if (currentInviteDate != 0) {
req.flags |= 1;
req.expire_date = 0;
edited = true;
}
}
i = usesChooseView.getSelectedIndex();
if (i < dispalyedUses.size()) {
int newLimit = dispalyedUses.get(i);
if (inviteToEdit.usage_limit != newLimit) {
req.flags |= 2;
req.usage_limit = newLimit;
edited = true;
}
} else {
if (inviteToEdit.usage_limit != 0) {
req.flags |= 2;
req.usage_limit = 0;
edited = true;
}
}
if (inviteToEdit.request_needed != approveCell.isChecked()) {
req.flags |= 8;
req.request_needed = approveCell.isChecked();
if (req.request_needed) {
req.flags |= 2;
req.usage_limit = 0;
}
edited = true;
}
String newTitle = nameEditText.getText().toString();
if (!TextUtils.equals(inviteToEdit.title, newTitle)) {
req.title = newTitle;
req.flags |= 16;
edited = true;
}
if (edited) {
loading = true;
progressDialog = new AlertDialog(getParentActivity(), 3);
progressDialog.showDelayed(500);
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
loading = false;
if (progressDialog != null) {
progressDialog.dismiss();
}
if (error == null) {
if (response instanceof TLRPC.TL_messages_exportedChatInvite) {
inviteToEdit = (TLRPC.TL_chatInviteExported) ((TLRPC.TL_messages_exportedChatInvite) response).invite;
}
if (callback != null) {
callback.onLinkEdited(inviteToEdit, response);
}
finishFragment();
} else {
AlertsCreator.showSimpleAlert(LinkEditActivity.this, error.text);
}
}));
} else {
finishFragment();
}
}
}
use of org.telegram.ui.ActionBar.AlertDialog in project Telegram-FOSS by Telegram-FOSS-Team.
the class LogoutActivity method createView.
@Override
public View createView(Context context) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setTitle(LocaleController.getString("LogOutTitle", R.string.LogOutTitle));
if (AndroidUtilities.isTablet()) {
actionBar.setOccupyStatusBar(false);
}
actionBar.setAllowOverlayTitle(true);
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
}
}
});
listAdapter = new ListAdapter(context);
fragmentView = new FrameLayout(context);
fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
FrameLayout frameLayout = (FrameLayout) fragmentView;
listView = new RecyclerListView(context);
listView.setVerticalScrollBarEnabled(false);
listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
listView.setAdapter(listAdapter);
listView.setOnItemClickListener((view, position, x, y) -> {
if (position == addAccountRow) {
int freeAccount = -1;
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
if (!UserConfig.getInstance(a).isClientActivated()) {
freeAccount = a;
break;
}
}
if (freeAccount >= 0) {
presentFragment(new LoginActivity(freeAccount));
}
} else if (position == passcodeRow) {
presentFragment(new PasscodeActivity(0));
} else if (position == cacheRow) {
presentFragment(new CacheControlActivity());
} else if (position == phoneRow) {
presentFragment(new ActionIntroActivity(ActionIntroActivity.ACTION_TYPE_CHANGE_PHONE_NUMBER));
} else if (position == supportRow) {
showDialog(AlertsCreator.createSupportAlert(LogoutActivity.this));
} else if (position == logoutRow) {
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
UserConfig userConfig = getUserConfig();
builder.setMessage(LocaleController.getString("AreYouSureLogout", R.string.AreYouSureLogout));
builder.setTitle(LocaleController.getString("LogOut", R.string.LogOut));
builder.setPositiveButton(LocaleController.getString("LogOut", R.string.LogOut), (dialogInterface, i) -> MessagesController.getInstance(currentAccount).performLogout(1));
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
AlertDialog alertDialog = builder.create();
showDialog(alertDialog);
TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
if (button != null) {
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
}
}
});
return fragmentView;
}
use of org.telegram.ui.ActionBar.AlertDialog in project Telegram-FOSS by Telegram-FOSS-Team.
the class PassportActivity method needShowProgress.
public void needShowProgress() {
if (getParentActivity() == null || getParentActivity().isFinishing() || progressDialog != null) {
return;
}
progressDialog = new AlertDialog(getParentActivity(), 3);
progressDialog.setCanCacnel(false);
progressDialog.show();
}
use of org.telegram.ui.ActionBar.AlertDialog in project Telegram-FOSS by Telegram-FOSS-Team.
the class PassportActivity method createManageInterface.
private void createManageInterface(Context context) {
FrameLayout frameLayout = (FrameLayout) fragmentView;
actionBar.setTitle(LocaleController.getString("TelegramPassport", R.string.TelegramPassport));
actionBar.createMenu().addItem(info_item, R.drawable.profile_info);
headerCell = new HeaderCell(context);
headerCell.setText(LocaleController.getString("PassportProvidedInformation", R.string.PassportProvidedInformation));
headerCell.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
linearLayout2.addView(headerCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
sectionCell = new ShadowSectionCell(context);
sectionCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
linearLayout2.addView(sectionCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
addDocumentCell = new TextSettingsCell(context);
addDocumentCell.setBackgroundDrawable(Theme.getSelectorDrawable(true));
addDocumentCell.setText(LocaleController.getString("PassportNoDocumentsAdd", R.string.PassportNoDocumentsAdd), true);
linearLayout2.addView(addDocumentCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
addDocumentCell.setOnClickListener(v -> openAddDocumentAlert());
deletePassportCell = new TextSettingsCell(context);
deletePassportCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText3));
deletePassportCell.setBackgroundDrawable(Theme.getSelectorDrawable(true));
deletePassportCell.setText(LocaleController.getString("TelegramPassportDelete", R.string.TelegramPassportDelete), false);
linearLayout2.addView(deletePassportCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
deletePassportCell.setOnClickListener(v -> {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("TelegramPassportDeleteTitle", R.string.TelegramPassportDeleteTitle));
builder.setMessage(LocaleController.getString("TelegramPassportDeleteAlert", R.string.TelegramPassportDeleteAlert));
builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialog, which) -> {
TLRPC.TL_account_deleteSecureValue req = new TLRPC.TL_account_deleteSecureValue();
for (int a = 0; a < currentForm.values.size(); a++) {
req.types.add(currentForm.values.get(a).type);
}
needShowProgress();
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
for (int a = 0; a < linearLayout2.getChildCount(); a++) {
View child = linearLayout2.getChildAt(a);
if (child instanceof TextDetailSecureCell) {
linearLayout2.removeView(child);
a--;
}
}
needHideProgress();
typesViews.clear();
typesValues.clear();
currentForm.values.clear();
updateManageVisibility();
}));
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
AlertDialog alertDialog = builder.create();
showDialog(alertDialog);
TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
if (button != null) {
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
}
});
addDocumentSectionCell = new ShadowSectionCell(context);
addDocumentSectionCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
linearLayout2.addView(addDocumentSectionCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
emptyLayout = new LinearLayout(context);
emptyLayout.setOrientation(LinearLayout.VERTICAL);
emptyLayout.setGravity(Gravity.CENTER);
emptyLayout.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
if (AndroidUtilities.isTablet()) {
linearLayout2.addView(emptyLayout, new LinearLayout.LayoutParams(LayoutHelper.MATCH_PARENT, AndroidUtilities.dp(528) - ActionBar.getCurrentActionBarHeight()));
} else {
linearLayout2.addView(emptyLayout, new LinearLayout.LayoutParams(LayoutHelper.MATCH_PARENT, AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight()));
}
emptyImageView = new ImageView(context);
emptyImageView.setImageResource(R.drawable.no_passport);
emptyImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_sessions_devicesImage), PorterDuff.Mode.MULTIPLY));
emptyLayout.addView(emptyImageView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
emptyTextView1 = new TextView(context);
emptyTextView1.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
emptyTextView1.setGravity(Gravity.CENTER);
emptyTextView1.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
emptyTextView1.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
emptyTextView1.setText(LocaleController.getString("PassportNoDocuments", R.string.PassportNoDocuments));
emptyLayout.addView(emptyTextView1, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 0, 16, 0, 0));
emptyTextView2 = new TextView(context);
emptyTextView2.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
emptyTextView2.setGravity(Gravity.CENTER);
emptyTextView2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
emptyTextView2.setPadding(AndroidUtilities.dp(20), 0, AndroidUtilities.dp(20), 0);
emptyTextView2.setText(LocaleController.getString("PassportNoDocumentsInfo", R.string.PassportNoDocumentsInfo));
emptyLayout.addView(emptyTextView2, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 0, 14, 0, 0));
emptyTextView3 = new TextView(context);
emptyTextView3.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText4));
emptyTextView3.setGravity(Gravity.CENTER);
emptyTextView3.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
emptyTextView3.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
emptyTextView3.setGravity(Gravity.CENTER);
emptyTextView3.setText(LocaleController.getString("PassportNoDocumentsAdd", R.string.PassportNoDocumentsAdd).toUpperCase());
emptyLayout.addView(emptyTextView3, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 30, Gravity.CENTER, 0, 16, 0, 0));
emptyTextView3.setOnClickListener(v -> openAddDocumentAlert());
for (int a = 0, size = currentForm.values.size(); a < size; a++) {
TLRPC.TL_secureValue value = currentForm.values.get(a);
TLRPC.TL_secureRequiredType requiredType;
ArrayList<TLRPC.TL_secureRequiredType> documentTypes;
boolean documentOnly;
if (isPersonalDocument(value.type)) {
documentTypes = new ArrayList<>();
requiredType = new TLRPC.TL_secureRequiredType();
requiredType.type = value.type;
requiredType.selfie_required = true;
requiredType.translation_required = true;
documentTypes.add(requiredType);
requiredType = new TLRPC.TL_secureRequiredType();
requiredType.type = new TLRPC.TL_secureValueTypePersonalDetails();
documentOnly = true;
} else if (isAddressDocument(value.type)) {
documentTypes = new ArrayList<>();
requiredType = new TLRPC.TL_secureRequiredType();
requiredType.type = value.type;
requiredType.translation_required = true;
documentTypes.add(requiredType);
requiredType = new TLRPC.TL_secureRequiredType();
requiredType.type = new TLRPC.TL_secureValueTypeAddress();
documentOnly = true;
} else {
requiredType = new TLRPC.TL_secureRequiredType();
requiredType.type = value.type;
documentTypes = null;
documentOnly = false;
}
addField(context, requiredType, documentTypes, documentOnly, a == size - 1);
}
updateManageVisibility();
}
use of org.telegram.ui.ActionBar.AlertDialog in project Telegram-FOSS by Telegram-FOSS-Team.
the class DialogOrContactPickerActivity method showBlockAlert.
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).blockPeer(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));
}
}
Aggregations