Search in sources :

Example 11 with Builder

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();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Builder(androidx.appcompat.app.AlertDialog.Builder) Builder(androidx.appcompat.app.AlertDialog.Builder)

Example 12 with Builder

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();
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) XmppConnectionService(eu.siacs.conversations.services.XmppConnectionService) PackageManager(android.content.pm.PackageManager) Builder(androidx.appcompat.app.AlertDialog.Builder) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) Uri(android.net.Uri)

Example 13 with Builder

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();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Bitmap(android.graphics.Bitmap) Builder(androidx.appcompat.app.AlertDialog.Builder) Builder(androidx.appcompat.app.AlertDialog.Builder) Point(android.graphics.Point) ImageView(android.widget.ImageView) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 14 with Builder

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();
    });
}
Also used : EditText(android.widget.EditText) Builder(androidx.appcompat.app.AlertDialog.Builder) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 15 with Builder

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