use of android.app.AlertDialog.Builder in project Pix-Art-Messenger by kriztan.
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 android.app.AlertDialog.Builder in project Pix-Art-Messenger by kriztan.
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();
});
}
use of android.app.AlertDialog.Builder in project Pix-Art-Messenger by kriztan.
the class XmppActivity method showInstallPgpDialog.
public void showInstallPgpDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getString(R.string.openkeychain_required));
builder.setIconAttribute(android.R.attr.alertDialogIcon);
builder.setMessage(getText(R.string.openkeychain_required_long));
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 android.app.AlertDialog.Builder in project Pix-Art-Messenger by kriztan.
the class XmppActivity method openInstallFromUnknownSourcesDialogIfNeeded.
protected void openInstallFromUnknownSourcesDialogIfNeeded() {
if (!installFromUnknownSourceAllowed()) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.install_from_unknown_sources_disabled);
builder.setMessage(R.string.install_from_unknown_sources_disabled_dialog);
builder.setPositiveButton(R.string.next, (dialog, which) -> {
Intent intent = null;
if (android.os.Build.VERSION.SDK_INT >= 26) {
intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES);
Uri uri = Uri.parse("package:" + getPackageName());
intent.setData(uri);
} else {
intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
}
Log.d(Config.LOGTAG, "Allow install from unknown sources for Android SDK " + Build.VERSION.SDK_INT + " intent " + intent.toString());
try {
startActivityForResult(intent, REQUEST_UNKNOWN_SOURCE_OP);
} catch (ActivityNotFoundException e) {
Toast.makeText(XmppActivity.this, R.string.device_does_not_support_battery_op, Toast.LENGTH_SHORT).show();
}
});
builder.create().show();
}
}
use of android.app.AlertDialog.Builder in project Pix-Art-Messenger by kriztan.
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 AlertDialog.Builder builder = new AlertDialog.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();
});
}
Aggregations