Search in sources :

Example 26 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project Conversations by siacs.

the class StartConversationActivity method displayVerificationWarningDialog.

private void displayVerificationWarningDialog(final Contact contact, final Invite invite) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.verify_omemo_keys);
    View view = getLayoutInflater().inflate(R.layout.dialog_verify_fingerprints, null);
    final CheckBox isTrustedSource = view.findViewById(R.id.trusted_source);
    TextView warning = view.findViewById(R.id.warning);
    warning.setText(JidDialog.style(this, R.string.verifying_omemo_keys_trusted_source, contact.getJid().asBareJid().toEscapedString(), contact.getDisplayName()));
    builder.setView(view);
    builder.setPositiveButton(R.string.confirm, (dialog, which) -> {
        if (isTrustedSource.isChecked() && invite.hasFingerprints()) {
            xmppConnectionService.verifyFingerprints(contact, invite.getFingerprints());
        }
        switchToConversationDoNotAppend(contact, invite.getBody());
    });
    builder.setNegativeButton(R.string.cancel, (dialog, which) -> StartConversationActivity.this.finish());
    AlertDialog dialog = builder.create();
    dialog.setCanceledOnTouchOutside(false);
    dialog.setOnCancelListener(dialog1 -> StartConversationActivity.this.finish());
    dialog.show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) CheckBox(android.widget.CheckBox) TextView(android.widget.TextView) AutoCompleteTextView(android.widget.AutoCompleteTextView) SpeedDialView(com.leinardi.android.speeddial.SpeedDialView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AutoCompleteTextView(android.widget.AutoCompleteTextView)

Example 27 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project Conversations by siacs.

the class StartConversationActivity method askForContactsPermissions.

private void askForContactsPermissions() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
            if (mRequestedContactsPermission.compareAndSet(false, true)) {
                if (QuickConversationsService.isQuicksy() || shouldShowRequestPermissionRationale(Manifest.permission.READ_CONTACTS)) {
                    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    final AtomicBoolean requestPermission = new AtomicBoolean(false);
                    builder.setTitle(R.string.sync_with_contacts);
                    if (QuickConversationsService.isQuicksy()) {
                        builder.setMessage(Html.fromHtml(getString(R.string.sync_with_contacts_quicksy)));
                    } else {
                        builder.setMessage(getString(R.string.sync_with_contacts_long, getString(R.string.app_name)));
                    }
                    @StringRes int confirmButtonText;
                    if (QuickConversationsService.isConversations()) {
                        confirmButtonText = R.string.next;
                    } else {
                        confirmButtonText = R.string.confirm;
                    }
                    builder.setPositiveButton(confirmButtonText, (dialog, which) -> {
                        if (requestPermission.compareAndSet(false, true)) {
                            requestPermissions(new String[] { Manifest.permission.READ_CONTACTS }, REQUEST_SYNC_CONTACTS);
                        }
                    });
                    builder.setOnDismissListener(dialog -> {
                        if (QuickConversationsService.isConversations() && requestPermission.compareAndSet(false, true)) {
                            requestPermissions(new String[] { Manifest.permission.READ_CONTACTS }, REQUEST_SYNC_CONTACTS);
                        }
                    });
                    builder.setCancelable(QuickConversationsService.isQuicksy());
                    final AlertDialog dialog = builder.create();
                    dialog.setCanceledOnTouchOutside(QuickConversationsService.isQuicksy());
                    dialog.setOnShowListener(dialogInterface -> {
                        final TextView tv = dialog.findViewById(android.R.id.message);
                        if (tv != null) {
                            tv.setMovementMethod(LinkMovementMethod.getInstance());
                        }
                    });
                    dialog.show();
                } else {
                    requestPermissions(new String[] { Manifest.permission.READ_CONTACTS }, REQUEST_SYNC_CONTACTS);
                }
            }
        }
    }
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) StringRes(androidx.annotation.StringRes) TextView(android.widget.TextView) AutoCompleteTextView(android.widget.AutoCompleteTextView) SuppressLint(android.annotation.SuppressLint)

Example 28 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project Conversations by siacs.

the class SettingsActivity method deleteOmemoIdentities.

private boolean deleteOmemoIdentities() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.pref_delete_omemo_identities);
    final List<CharSequence> accounts = new ArrayList<>();
    for (Account account : xmppConnectionService.getAccounts()) {
        if (account.isEnabled()) {
            accounts.add(account.getJid().asBareJid().toString());
        }
    }
    final boolean[] checkedItems = new boolean[accounts.size()];
    builder.setMultiChoiceItems(accounts.toArray(new CharSequence[accounts.size()]), checkedItems, (dialog, which, isChecked) -> {
        checkedItems[which] = isChecked;
        final AlertDialog alertDialog = (AlertDialog) dialog;
        for (boolean item : checkedItems) {
            if (item) {
                alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(true);
                return;
            }
        }
        alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(false);
    });
    builder.setNegativeButton(R.string.cancel, null);
    builder.setPositiveButton(R.string.delete_selected_keys, (dialog, which) -> {
        for (int i = 0; i < checkedItems.length; ++i) {
            if (checkedItems[i]) {
                try {
                    Jid jid = Jid.of(accounts.get(i).toString());
                    Account account = xmppConnectionService.findAccountByJid(jid);
                    if (account != null) {
                        account.getAxolotlService().regenerateKeys(true);
                    }
                } catch (IllegalArgumentException e) {
                // 
                }
            }
        }
    });
    AlertDialog dialog = builder.create();
    dialog.show();
    dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
    return true;
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Account(eu.siacs.conversations.entities.Account) Jid(eu.siacs.conversations.xmpp.Jid) ArrayList(java.util.ArrayList)

Example 29 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project Conversations by siacs.

the class EditAccountActivity method displayVerificationWarningDialog.

private void displayVerificationWarningDialog(final XmppUri xmppUri) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.verify_omemo_keys);
    View view = getLayoutInflater().inflate(R.layout.dialog_verify_fingerprints, null);
    final CheckBox isTrustedSource = view.findViewById(R.id.trusted_source);
    TextView warning = view.findViewById(R.id.warning);
    warning.setText(R.string.verifying_omemo_keys_trusted_source_account);
    builder.setView(view);
    builder.setPositiveButton(R.string.continue_btn, (dialog, which) -> {
        if (isTrustedSource.isChecked()) {
            processFingerprintVerification(xmppUri, false);
        } else {
            finish();
        }
    });
    builder.setNegativeButton(R.string.cancel, (dialog, which) -> finish());
    AlertDialog dialog = builder.create();
    dialog.setCanceledOnTouchOutside(false);
    dialog.setOnCancelListener(d -> finish());
    dialog.show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) CheckBox(android.widget.CheckBox) Builder(androidx.appcompat.app.AlertDialog.Builder) Builder(androidx.appcompat.app.AlertDialog.Builder) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 30 with AlertDialog

use of androidx.appcompat.app.AlertDialog in project Conversations by siacs.

the class JoinConferenceDialog method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.join_public_channel);
    DialogJoinConferenceBinding binding = DataBindingUtil.inflate(getActivity().getLayoutInflater(), R.layout.dialog_join_conference, null, false);
    DelayedHintHelper.setHint(R.string.channel_full_jid_example, binding.jid);
    this.knownHostsAdapter = new KnownHostsAdapter(getActivity(), R.layout.simple_list_item);
    binding.jid.setAdapter(knownHostsAdapter);
    String prefilledJid = getArguments().getString(PREFILLED_JID_KEY);
    if (prefilledJid != null) {
        binding.jid.append(prefilledJid);
    }
    StartConversationActivity.populateAccountSpinner(getActivity(), getArguments().getStringArrayList(ACCOUNTS_LIST_KEY), binding.account);
    builder.setView(binding.getRoot());
    builder.setPositiveButton(R.string.join, null);
    builder.setNegativeButton(R.string.cancel, null);
    AlertDialog dialog = builder.create();
    dialog.show();
    dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(view -> mListener.onJoinDialogPositiveClick(dialog, binding.account, binding.accountJidLayout, binding.jid, binding.bookmark.isChecked()));
    binding.jid.setOnEditorActionListener((v, actionId, event) -> {
        mListener.onJoinDialogPositiveClick(dialog, binding.account, binding.accountJidLayout, binding.jid, binding.bookmark.isChecked());
        return true;
    });
    return dialog;
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) KnownHostsAdapter(eu.siacs.conversations.ui.adapter.KnownHostsAdapter) DialogJoinConferenceBinding(eu.siacs.conversations.databinding.DialogJoinConferenceBinding) NonNull(androidx.annotation.NonNull)

Aggregations

AlertDialog (androidx.appcompat.app.AlertDialog)261 Test (org.junit.Test)89 View (android.view.View)49 DialogInterface (android.content.DialogInterface)42 TextView (android.widget.TextView)40 Button (android.widget.Button)39 Intent (android.content.Intent)30 ShadowAlertDialogCompat (com.android.settings.testutils.shadow.ShadowAlertDialogCompat)30 NonNull (androidx.annotation.NonNull)28 Context (android.content.Context)26 Bundle (android.os.Bundle)20 EditText (android.widget.EditText)18 MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)18 SuppressLint (android.annotation.SuppressLint)17 ArrayList (java.util.ArrayList)17 List (java.util.List)12 Activity (android.app.Activity)11 Uri (android.net.Uri)11 LayoutInflater (android.view.LayoutInflater)11 ListView (android.widget.ListView)10