Search in sources :

Example 1 with Builder

use of androidx.appcompat.app.AlertDialog.Builder in project android by owncloud.

the class ReceiveExternalFilesActivity method showUploadTextDialog.

/**
 * Show a dialog where the user can enter a filename for the file he wants to place the text in.
 */
private void showUploadTextDialog() {
    final AlertDialog.Builder builder = new Builder(this);
    final View dialogView = getLayoutInflater().inflate(R.layout.dialog_upload_text, null);
    builder.setView(dialogView);
    builder.setTitle(R.string.uploader_upload_text_dialog_title);
    builder.setCancelable(false);
    builder.setPositiveButton(R.string.uploader_btn_upload_text, null);
    builder.setNegativeButton(android.R.string.cancel, null);
    final TextInputEditText input = dialogView.findViewById(R.id.inputFileName);
    final TextInputLayout inputLayout = dialogView.findViewById(R.id.inputTextLayout);
    input.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            inputLayout.setError(null);
            inputLayout.setErrorEnabled(false);
        }
    });
    final AlertDialog alertDialog = builder.create();
    setFileNameFromIntent(alertDialog, input);
    alertDialog.setOnShowListener(dialog -> {
        Button button = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
        button.setOnClickListener(view -> {
            String fileName = input.getText().toString();
            String error = null;
            if (fileName.length() > MAX_FILENAME_LENGTH) {
                error = String.format(getString(R.string.uploader_upload_text_dialog_filename_error_length_max), MAX_FILENAME_LENGTH);
            } else if (fileName.length() == 0) {
                error = getString(R.string.uploader_upload_text_dialog_filename_error_empty);
            } else {
                fileName += ".txt";
                Uri fileUri = savePlainTextToFile(fileName);
                mStreamsToUpload.clear();
                mStreamsToUpload.add(fileUri);
                uploadFiles();
            }
            inputLayout.setErrorEnabled(error != null);
            inputLayout.setError(error);
        });
    });
    alertDialog.show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Builder(androidx.appcompat.app.AlertDialog.Builder) Builder(androidx.appcompat.app.AlertDialog.Builder) View(android.view.View) AdapterView(android.widget.AdapterView) SearchView(androidx.appcompat.widget.SearchView) TextView(android.widget.TextView) ListView(android.widget.ListView) SortOptionsView(com.owncloud.android.presentation.ui.files.SortOptionsView) Uri(android.net.Uri) Button(android.widget.Button) TextInputEditText(com.google.android.material.textfield.TextInputEditText) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextInputLayout(com.google.android.material.textfield.TextInputLayout)

Example 2 with Builder

use of androidx.appcompat.app.AlertDialog.Builder 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 3 with Builder

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

the class EditAccountActivity method changePresence.

private void changePresence() {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    boolean manualStatus = sharedPreferences.getBoolean(SettingsActivity.MANUALLY_CHANGE_PRESENCE, getResources().getBoolean(R.bool.manually_change_presence));
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    final DialogPresenceBinding binding = DataBindingUtil.inflate(getLayoutInflater(), R.layout.dialog_presence, null, false);
    String current = mAccount.getPresenceStatusMessage();
    if (current != null && !current.trim().isEmpty()) {
        binding.statusMessage.append(current);
    }
    setAvailabilityRadioButton(mAccount.getPresenceStatus(), binding);
    binding.show.setVisibility(manualStatus ? View.VISIBLE : View.GONE);
    List<PresenceTemplate> templates = xmppConnectionService.getPresenceTemplates(mAccount);
    PresenceTemplateAdapter presenceTemplateAdapter = new PresenceTemplateAdapter(this, R.layout.simple_list_item, templates);
    binding.statusMessage.setAdapter(presenceTemplateAdapter);
    binding.statusMessage.setOnItemClickListener((parent, view, position, id) -> {
        PresenceTemplate template = (PresenceTemplate) parent.getItemAtPosition(position);
        setAvailabilityRadioButton(template.getStatus(), binding);
    });
    builder.setTitle(R.string.edit_status_message_title);
    builder.setView(binding.getRoot());
    builder.setNegativeButton(R.string.cancel, null);
    builder.setPositiveButton(R.string.confirm, (dialog, which) -> {
        PresenceTemplate template = new PresenceTemplate(getAvailabilityRadioButton(binding), binding.statusMessage.getText().toString().trim());
        if (mAccount.getPgpId() != 0 && hasPgp()) {
            generateSignature(null, template);
        } else {
            xmppConnectionService.changeStatus(mAccount, template, null);
        }
    });
    builder.create().show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) DialogPresenceBinding(eu.siacs.conversations.databinding.DialogPresenceBinding) SharedPreferences(android.content.SharedPreferences) Builder(androidx.appcompat.app.AlertDialog.Builder) PresenceTemplateAdapter(eu.siacs.conversations.ui.adapter.PresenceTemplateAdapter) Builder(androidx.appcompat.app.AlertDialog.Builder) PresenceTemplate(eu.siacs.conversations.entities.PresenceTemplate)

Example 4 with Builder

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

the class EditAccountActivity method showDeletePgpDialog.

private void showDeletePgpDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.unpublish_pgp);
    builder.setMessage(R.string.unpublish_pgp_message);
    builder.setNegativeButton(R.string.cancel, null);
    builder.setPositiveButton(R.string.confirm, (dialogInterface, i) -> {
        mAccount.setPgpSignId(0);
        mAccount.unsetPgpSignature();
        xmppConnectionService.databaseBackend.updateAccount(mAccount);
        xmppConnectionService.sendPresence(mAccount);
        refreshUiReal();
    });
    builder.create().show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Builder(androidx.appcompat.app.AlertDialog.Builder) Builder(androidx.appcompat.app.AlertDialog.Builder)

Example 5 with Builder

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

the class XmppActivity method displayErrorDialog.

protected void displayErrorDialog(final int errorCode) {
    runOnUiThread(() -> {
        Builder builder = new Builder(XmppActivity.this);
        builder.setIconAttribute(android.R.attr.alertDialogIcon);
        builder.setTitle(getString(R.string.error));
        builder.setMessage(errorCode);
        builder.setNeutralButton(R.string.accept, null);
        builder.create().show();
    });
}
Also used : Builder(androidx.appcompat.app.AlertDialog.Builder)

Aggregations

Builder (androidx.appcompat.app.AlertDialog.Builder)16 AlertDialog (androidx.appcompat.app.AlertDialog)10 View (android.view.View)4 ImageView (android.widget.ImageView)4 Intent (android.content.Intent)3 Uri (android.net.Uri)3 SuppressLint (android.annotation.SuppressLint)2 PendingIntent (android.app.PendingIntent)2 Context (android.content.Context)2 DialogInterface (android.content.DialogInterface)2 SharedPreferences (android.content.SharedPreferences)2 PackageManager (android.content.pm.PackageManager)2 ResolveInfo (android.content.pm.ResolveInfo)2 Bitmap (android.graphics.Bitmap)2 Point (android.graphics.Point)2 TextView (android.widget.TextView)2 XmppConnectionService (eu.siacs.conversations.services.XmppConnectionService)2 IOException (java.io.IOException)2 Manifest (android.Manifest)1 Account (android.accounts.Account)1