Search in sources :

Example 91 with Builder

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Builder(android.app.AlertDialog.Builder) Builder(android.app.AlertDialog.Builder)

Example 92 with Builder

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

Example 93 with Builder

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) ResolveInfo(android.content.pm.ResolveInfo) XmppConnectionService(de.pixart.messenger.services.XmppConnectionService) PackageManager(android.content.pm.PackageManager) Builder(android.app.AlertDialog.Builder) Builder(android.app.AlertDialog.Builder) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) Uri(android.net.Uri)

Example 94 with Builder

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();
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) ActivityNotFoundException(android.content.ActivityNotFoundException) Builder(android.app.AlertDialog.Builder) Builder(android.app.AlertDialog.Builder) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) Uri(android.net.Uri)

Example 95 with Builder

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

Aggregations

Builder (android.app.AlertDialog.Builder)112 DialogInterface (android.content.DialogInterface)64 AlertDialog (android.app.AlertDialog)42 Intent (android.content.Intent)29 View (android.view.View)28 TextView (android.widget.TextView)25 OnClickListener (android.content.DialogInterface.OnClickListener)21 SuppressLint (android.annotation.SuppressLint)16 ArrayList (java.util.ArrayList)15 OnClickListener (android.view.View.OnClickListener)13 ImageView (android.widget.ImageView)13 Context (android.content.Context)12 AlertDialog (android.support.v7.app.AlertDialog)12 List (java.util.List)12 Bundle (android.os.Bundle)11 RelativeLayout (android.widget.RelativeLayout)10 Point (android.graphics.Point)9 ExpandableListView (android.widget.ExpandableListView)9 ImageButton (android.widget.ImageButton)7 EditText (android.widget.EditText)6