use of androidx.appcompat.app.AlertDialog.Builder in project Conversations by siacs.
the class XmppActivity method showAskForPresenceDialog.
private void showAskForPresenceDialog(final Contact contact) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(contact.getJid().toString());
builder.setMessage(R.string.request_presence_updates);
builder.setNegativeButton(R.string.cancel, null);
builder.setPositiveButton(R.string.request_now, (dialog, which) -> {
if (xmppConnectionServiceBound) {
xmppConnectionService.sendPresencePacket(contact.getAccount(), xmppConnectionService.getPresenceGenerator().requestPresenceUpdatesFrom(contact));
}
});
builder.create().show();
}
use of androidx.appcompat.app.AlertDialog.Builder in project Conversations by siacs.
the class XmppActivity method showInstallPgpDialog.
public void showInstallPgpDialog() {
Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getString(R.string.openkeychain_required));
builder.setIconAttribute(android.R.attr.alertDialogIcon);
builder.setMessage(Html.fromHtml(getString(R.string.openkeychain_required_long, getString(R.string.app_name))));
builder.setNegativeButton(getString(R.string.cancel), null);
builder.setNeutralButton(getString(R.string.restart), (dialog, which) -> {
if (xmppConnectionServiceBound) {
unbindService(mConnection);
xmppConnectionServiceBound = false;
}
stopService(new Intent(XmppActivity.this, XmppConnectionService.class));
finish();
});
builder.setPositiveButton(getString(R.string.install), (dialog, which) -> {
Uri uri = Uri.parse("market://details?id=org.sufficientlysecure.keychain");
Intent marketIntent = new Intent(Intent.ACTION_VIEW, uri);
PackageManager manager = getApplicationContext().getPackageManager();
List<ResolveInfo> infos = manager.queryIntentActivities(marketIntent, 0);
if (infos.size() > 0) {
startActivity(marketIntent);
} else {
uri = Uri.parse("http://www.openkeychain.org/");
Intent browserIntent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(browserIntent);
}
finish();
});
builder.create().show();
}
use of androidx.appcompat.app.AlertDialog.Builder in project Conversations by siacs.
the class XmppActivity method showQrCode.
protected void showQrCode(final String uri) {
if (uri == null || uri.isEmpty()) {
return;
}
Point size = new Point();
getWindowManager().getDefaultDisplay().getSize(size);
final int width = (size.x < size.y ? size.x : size.y);
Bitmap bitmap = BarcodeProvider.create2dBarcodeBitmap(uri, width);
ImageView view = new ImageView(this);
view.setBackgroundColor(Color.WHITE);
view.setImageBitmap(bitmap);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(view);
builder.create().show();
}
use of androidx.appcompat.app.AlertDialog.Builder in project Conversations by siacs.
the class EditAccountActivity method onCaptchaRequested.
@Override
public void onCaptchaRequested(final Account account, final String id, final Data data, final Bitmap captcha) {
runOnUiThread(() -> {
if (mCaptchaDialog != null && mCaptchaDialog.isShowing()) {
mCaptchaDialog.dismiss();
}
final Builder builder = new Builder(EditAccountActivity.this);
final View view = getLayoutInflater().inflate(R.layout.captcha, null);
final ImageView imageView = view.findViewById(R.id.captcha);
final EditText input = view.findViewById(R.id.input);
imageView.setImageBitmap(captcha);
builder.setTitle(getString(R.string.captcha_required));
builder.setView(view);
builder.setPositiveButton(getString(R.string.ok), (dialog, which) -> {
String rc = input.getText().toString();
data.put("username", account.getUsername());
data.put("password", account.getPassword());
data.put("ocr", rc);
data.submit();
if (xmppConnectionServiceBound) {
xmppConnectionService.sendCreateAccountWithCaptchaPacket(account, id, data);
}
});
builder.setNegativeButton(getString(R.string.cancel), (dialog, which) -> {
if (xmppConnectionService != null) {
xmppConnectionService.sendCreateAccountWithCaptchaPacket(account, null, null);
}
});
builder.setOnCancelListener(dialog -> {
if (xmppConnectionService != null) {
xmppConnectionService.sendCreateAccountWithCaptchaPacket(account, null, null);
}
});
mCaptchaDialog = builder.create();
mCaptchaDialog.show();
input.requestFocus();
});
}
use of androidx.appcompat.app.AlertDialog.Builder in project Conversations by siacs.
the class EditAccountActivity method showWipePepDialog.
public void showWipePepDialog() {
Builder builder = new Builder(this);
builder.setTitle(getString(R.string.clear_other_devices));
builder.setIconAttribute(android.R.attr.alertDialogIcon);
builder.setMessage(getString(R.string.clear_other_devices_desc));
builder.setNegativeButton(getString(R.string.cancel), null);
builder.setPositiveButton(getString(R.string.accept), (dialog, which) -> mAccount.getAxolotlService().wipeOtherPepDevices());
builder.create().show();
}
Aggregations