use of androidx.appcompat.app.AlertDialog.Builder in project Conversations by siacs.
the class XmppActivity method showAddToRosterDialog.
protected void showAddToRosterDialog(final Contact contact) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(contact.getJid().toString());
builder.setMessage(getString(R.string.not_in_roster));
builder.setNegativeButton(getString(R.string.cancel), null);
builder.setPositiveButton(getString(R.string.add_contact), (dialog, which) -> xmppConnectionService.createContact(contact, true));
builder.create().show();
}
use of androidx.appcompat.app.AlertDialog.Builder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ChooseLockTypeDialogFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Context context = getContext();
Builder builder = new Builder(context);
List<ScreenLockType> locks = mController.getVisibleScreenLockTypes(DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, false);
mAdapter = new ScreenLockAdapter(context, locks, mController);
builder.setAdapter(mAdapter, this);
builder.setTitle(R.string.setup_lock_settings_options_dialog_title);
Dialog alertDialog = builder.create();
return alertDialog;
}
use of androidx.appcompat.app.AlertDialog.Builder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RadioInfo method showDsdsChangeDialog.
private void showDsdsChangeDialog() {
final AlertDialog confirmDialog = new Builder(RadioInfo.this).setTitle(R.string.dsds_dialog_title).setMessage(R.string.dsds_dialog_message).setPositiveButton(R.string.dsds_dialog_confirm, mOnDsdsDialogConfirmedListener).setNegativeButton(R.string.dsds_dialog_cancel, mOnDsdsDialogConfirmedListener).create();
confirmDialog.show();
}
use of androidx.appcompat.app.AlertDialog.Builder in project android by owncloud.
the class ReceiveExternalFilesActivity method onCreateDialog.
@Override
protected Dialog onCreateDialog(final int id) {
final AlertDialog.Builder builder = new Builder(this);
switch(id) {
case DIALOG_NO_ACCOUNT:
builder.setIcon(R.drawable.ic_warning);
builder.setTitle(R.string.uploader_wrn_no_account_title);
builder.setMessage(String.format(getString(R.string.uploader_wrn_no_account_text), getString(R.string.app_name)));
builder.setCancelable(false);
builder.setPositiveButton(R.string.uploader_wrn_no_account_setup_btn_text, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT);
intent.putExtra("authorities", new String[] { MainApp.Companion.getAuthTokenType() });
startActivityForResult(intent, REQUEST_CODE__SETUP_ACCOUNT);
}
});
builder.setNegativeButton(R.string.uploader_wrn_no_account_quit_btn_text, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
return builder.create();
case DIALOG_MULTIPLE_ACCOUNT:
Account[] accounts = mAccountManager.getAccountsByType(MainApp.Companion.getAccountType());
CharSequence[] dialogItems = new CharSequence[accounts.length];
OwnCloudAccount oca;
for (int i = 0; i < dialogItems.length; ++i) {
try {
oca = new OwnCloudAccount(accounts[i], this);
dialogItems[i] = oca.getDisplayName() + " @ " + DisplayUtils.convertIdn(accounts[i].name.substring(accounts[i].name.lastIndexOf("@") + 1), false);
} catch (Exception e) {
Timber.w("Couldn't read display name of account; using account name instead");
dialogItems[i] = DisplayUtils.convertIdn(accounts[i].name, false);
}
}
builder.setTitle(R.string.common_choose_account);
builder.setItems(dialogItems, (dialog, which) -> {
setAccount(mAccountManager.getAccountsByType(MainApp.Companion.getAccountType())[which]);
onAccountSet(mAccountWasRestored);
dialog.dismiss();
mAccountSelected = true;
mAccountSelectionShowing = false;
});
builder.setCancelable(true);
builder.setOnCancelListener(dialog -> {
mAccountSelectionShowing = false;
dialog.cancel();
finish();
});
return builder.create();
default:
throw new IllegalArgumentException("Unknown dialog id: " + id);
}
}
use of androidx.appcompat.app.AlertDialog.Builder in project Conversations by siacs.
the class XmppActivity method quickEdit.
@SuppressLint("InflateParams")
private void quickEdit(final String previousValue, final OnValueEdited callback, @StringRes final int hint, boolean password, boolean permitEmpty) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
DialogQuickeditBinding binding = DataBindingUtil.inflate(getLayoutInflater(), R.layout.dialog_quickedit, null, false);
if (password) {
binding.inputEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
}
builder.setPositiveButton(R.string.accept, null);
if (hint != 0) {
binding.inputLayout.setHint(getString(hint));
}
binding.inputEditText.requestFocus();
if (previousValue != null) {
binding.inputEditText.getText().append(previousValue);
}
builder.setView(binding.getRoot());
builder.setNegativeButton(R.string.cancel, null);
final AlertDialog dialog = builder.create();
dialog.setOnShowListener(d -> SoftKeyboardUtils.showKeyboard(binding.inputEditText));
dialog.show();
View.OnClickListener clickListener = v -> {
String value = binding.inputEditText.getText().toString();
if (!value.equals(previousValue) && (!value.trim().isEmpty() || permitEmpty)) {
String error = callback.onValueEdited(value);
if (error != null) {
binding.inputLayout.setError(error);
return;
}
}
SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText);
dialog.dismiss();
};
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(clickListener);
dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setOnClickListener((v -> {
SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText);
dialog.dismiss();
}));
dialog.setCanceledOnTouchOutside(false);
dialog.setOnDismissListener(dialog1 -> {
SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText);
});
}
Aggregations