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();
}
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();
}
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();
}
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();
}
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();
});
}
Aggregations