Search in sources :

Example 31 with AlertDialog

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();
        }
    }
}
Also used : AlertDialog(org.telegram.ui.ActionBar.AlertDialog) ThemeDescription(org.telegram.ui.ActionBar.ThemeDescription) Context(android.content.Context) LinearLayout(android.widget.LinearLayout) AdjustPanLayoutHelper(org.telegram.ui.ActionBar.AdjustPanLayoutHelper) Theme(org.telegram.ui.ActionBar.Theme) AndroidUtilities(org.telegram.messenger.AndroidUtilities) LocaleController(org.telegram.messenger.LocaleController) HeaderCell(org.telegram.ui.Cells.HeaderCell) AlertsCreator(org.telegram.ui.Components.AlertsCreator) Editable(android.text.Editable) TextInfoPrivacyCell(org.telegram.ui.Cells.TextInfoPrivacyCell) ArrayList(java.util.ArrayList) LayoutTransition(android.animation.LayoutTransition) SuppressLint(android.annotation.SuppressLint) SpannableStringBuilder(android.text.SpannableStringBuilder) MotionEvent(android.view.MotionEvent) TLRPC(org.telegram.tgnet.TLRPC) ActionBar(org.telegram.ui.ActionBar.ActionBar) TLObject(org.telegram.tgnet.TLObject) View(android.view.View) SizeNotifierFrameLayout(org.telegram.ui.Components.SizeNotifierFrameLayout) Canvas(android.graphics.Canvas) Emoji(org.telegram.messenger.Emoji) SlideChooseView(org.telegram.ui.Components.SlideChooseView) TextSettingsCell(org.telegram.ui.Cells.TextSettingsCell) R(org.telegram.messenger.R) InputType(android.text.InputType) TextUtils(android.text.TextUtils) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) LayoutHelper(org.telegram.ui.Components.LayoutHelper) Gravity(android.view.Gravity) TextView(android.widget.TextView) TypedValue(android.util.TypedValue) ScrollView(android.widget.ScrollView) TextCheckCell(org.telegram.ui.Cells.TextCheckCell) Vibrator(android.os.Vibrator) InputFilter(android.text.InputFilter) DigitsKeyListener(android.text.method.DigitsKeyListener) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) EditText(android.widget.EditText) TextWatcher(android.text.TextWatcher) Vibrator(android.os.Vibrator) SuppressLint(android.annotation.SuppressLint) TLRPC(org.telegram.tgnet.TLRPC)

Example 32 with AlertDialog

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;
}
Also used : AlertDialog(org.telegram.ui.ActionBar.AlertDialog) ThemeDescription(org.telegram.ui.ActionBar.ThemeDescription) Context(android.content.Context) Theme(org.telegram.ui.ActionBar.Theme) FrameLayout(android.widget.FrameLayout) AndroidUtilities(org.telegram.messenger.AndroidUtilities) Dialog(android.app.Dialog) LocaleController(org.telegram.messenger.LocaleController) HeaderCell(org.telegram.ui.Cells.HeaderCell) AlertsCreator(org.telegram.ui.Components.AlertsCreator) TextInfoPrivacyCell(org.telegram.ui.Cells.TextInfoPrivacyCell) ArrayList(java.util.ArrayList) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) TextDetailSettingsCell(org.telegram.ui.Cells.TextDetailSettingsCell) ActionBar(org.telegram.ui.ActionBar.ActionBar) AnimatorSet(android.animation.AnimatorSet) View(android.view.View) SharedConfig(org.telegram.messenger.SharedConfig) RecyclerView(androidx.recyclerview.widget.RecyclerView) DownloadController(org.telegram.messenger.DownloadController) DialogInterface(android.content.DialogInterface) TextSettingsCell(org.telegram.ui.Cells.TextSettingsCell) R(org.telegram.messenger.R) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) LayoutHelper(org.telegram.ui.Components.LayoutHelper) ViewGroup(android.view.ViewGroup) MessagesController(org.telegram.messenger.MessagesController) Gravity(android.view.Gravity) UserConfig(org.telegram.messenger.UserConfig) TextView(android.widget.TextView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) RecyclerListView(org.telegram.ui.Components.RecyclerListView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) UserConfig(org.telegram.messenger.UserConfig) FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView) ActionBar(org.telegram.ui.ActionBar.ActionBar)

Example 33 with AlertDialog

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();
}
Also used : AlertDialog(org.telegram.ui.ActionBar.AlertDialog)

Example 34 with AlertDialog

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();
}
Also used : AlertDialog(org.telegram.ui.ActionBar.AlertDialog) HeaderCell(org.telegram.ui.Cells.HeaderCell) SpannableStringBuilder(android.text.SpannableStringBuilder) ArrayList(java.util.ArrayList) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) TLRPC(org.telegram.tgnet.TLRPC) TextView(android.widget.TextView) ImageView(android.widget.ImageView) BackupImageView(org.telegram.ui.Components.BackupImageView) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) ImageView(android.widget.ImageView) SlideView(org.telegram.ui.Components.SlideView) ScrollView(android.widget.ScrollView) View(android.view.View) ContextProgressView(org.telegram.ui.Components.ContextProgressView) EmptyTextProgressView(org.telegram.ui.Components.EmptyTextProgressView) TextView(android.widget.TextView) BackupImageView(org.telegram.ui.Components.BackupImageView) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) TextSettingsCell(org.telegram.ui.Cells.TextSettingsCell) FrameLayout(android.widget.FrameLayout) LinearLayout(android.widget.LinearLayout)

Example 35 with AlertDialog

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));
    }
}
Also used : AlertDialog(org.telegram.ui.ActionBar.AlertDialog) TextView(android.widget.TextView)

Aggregations

AlertDialog (org.telegram.ui.ActionBar.AlertDialog)101 TLRPC (org.telegram.tgnet.TLRPC)71 TextView (android.widget.TextView)63 FrameLayout (android.widget.FrameLayout)47 ArrayList (java.util.ArrayList)47 Context (android.content.Context)45 View (android.view.View)44 AndroidUtilities (org.telegram.messenger.AndroidUtilities)41 LocaleController (org.telegram.messenger.LocaleController)41 Theme (org.telegram.ui.ActionBar.Theme)41 R (org.telegram.messenger.R)40 BaseFragment (org.telegram.ui.ActionBar.BaseFragment)40 LinearLayout (android.widget.LinearLayout)38 Paint (android.graphics.Paint)37 MessagesController (org.telegram.messenger.MessagesController)37 SuppressLint (android.annotation.SuppressLint)36 TextUtils (android.text.TextUtils)36 FileLog (org.telegram.messenger.FileLog)36 Build (android.os.Build)34 Gravity (android.view.Gravity)34