Search in sources :

Example 16 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project k-9 by k9mail.

the class PgpInlineDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Activity activity = getActivity();
    @SuppressLint("InflateParams") View view = LayoutInflater.from(activity).inflate(R.layout.openpgp_inline_dialog, null);
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setView(view);
    if (getArguments().getInt(ARG_FIRST_TIME) != 0) {
        builder.setPositiveButton(R.string.openpgp_inline_ok, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
    } else {
        builder.setPositiveButton(R.string.openpgp_inline_disable, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                Activity activity = getActivity();
                if (activity == null) {
                    return;
                }
                ((OnOpenPgpInlineChangeListener) activity).onOpenPgpInlineChange(false);
                dialog.dismiss();
            }
        });
        builder.setNegativeButton(R.string.openpgp_inline_keep_enabled, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
    }
    return builder.create();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Activity(android.app.Activity) SuppressLint(android.annotation.SuppressLint) OnClickListener(android.content.DialogInterface.OnClickListener) View(android.view.View) SuppressLint(android.annotation.SuppressLint)

Example 17 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project k-9 by k9mail.

the class CryptoInfoDialog method onCreateDialog.

// inflating without root element is fine for creating a dialog
@SuppressLint("InflateParams")
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Builder b = new AlertDialog.Builder(getActivity());
    dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.message_crypto_info_dialog, null);
    topIconFrame = dialogView.findViewById(R.id.crypto_info_top_frame);
    topIcon_1 = (ImageView) topIconFrame.findViewById(R.id.crypto_info_top_icon_1);
    topIcon_2 = (ImageView) topIconFrame.findViewById(R.id.crypto_info_top_icon_2);
    topIcon_3 = (ImageView) topIconFrame.findViewById(R.id.crypto_info_top_icon_3);
    topText = (TextView) dialogView.findViewById(R.id.crypto_info_top_text);
    bottomIconFrame = dialogView.findViewById(R.id.crypto_info_bottom_frame);
    bottomIcon_1 = (ImageView) bottomIconFrame.findViewById(R.id.crypto_info_bottom_icon_1);
    bottomIcon_2 = (ImageView) bottomIconFrame.findViewById(R.id.crypto_info_bottom_icon_2);
    bottomText = (TextView) dialogView.findViewById(R.id.crypto_info_bottom_text);
    MessageCryptoDisplayStatus displayStatus = MessageCryptoDisplayStatus.valueOf(getArguments().getString(ARG_DISPLAY_STATUS));
    setMessageForDisplayStatus(displayStatus);
    b.setView(dialogView);
    b.setPositiveButton(R.string.crypto_info_ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            dismiss();
        }
    });
    if (displayStatus.hasAssociatedKey()) {
        b.setNeutralButton(R.string.crypto_info_view_key, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Fragment frag = getTargetFragment();
                if (!(frag instanceof OnClickShowCryptoKeyListener)) {
                    throw new AssertionError("Displaying activity must implement OnClickShowCryptoKeyListener!");
                }
                ((OnClickShowCryptoKeyListener) frag).onClickShowCryptoKey();
            }
        });
    }
    return b.create();
}
Also used : DialogInterface(android.content.DialogInterface) Builder(android.app.AlertDialog.Builder) MessageCryptoDisplayStatus(com.fsck.k9.view.MessageCryptoDisplayStatus) OnClickListener(android.content.DialogInterface.OnClickListener) Fragment(android.app.Fragment) DialogFragment(android.app.DialogFragment) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 18 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project qksms by moezbhatti.

the class LogTag method warnPossibleRecipientMismatch.

public static void warnPossibleRecipientMismatch(final String msg, final Activity activity) {
    Log.e(TAG, "WARNING!!!! " + msg, new RuntimeException());
    if (SHOW_SEVERE_WARNING_DIALOG) {
        dumpInternalTables(activity);
        activity.runOnUiThread(new Runnable() {

            public void run() {
                new AlertDialog.Builder(activity).setIconAttribute(android.R.attr.alertDialogIcon).setTitle(R.string.error_state).setMessage(msg + "\n\n" + activity.getString(R.string.error_state_text)).setPositiveButton(R.string.yes, new OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                }).show();
            }
        });
    }
}
Also used : DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener)

Example 19 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project qksms by moezbhatti.

the class MessageUtils method handleReadReport.

public static void handleReadReport(final Context context, final Collection<Long> threadIds, final int status, final Runnable callback) {
    StringBuilder selectionBuilder = new StringBuilder(Mms.MESSAGE_TYPE + " = " + PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF + " AND " + Mms.READ + " = 0" + " AND " + Mms.READ_REPORT + " = " + PduHeaders.VALUE_YES);
    String[] selectionArgs = null;
    if (threadIds != null) {
        String threadIdSelection = null;
        StringBuilder buf = new StringBuilder();
        selectionArgs = new String[threadIds.size()];
        int i = 0;
        for (long threadId : threadIds) {
            if (i > 0) {
                buf.append(" OR ");
            }
            buf.append(Mms.THREAD_ID).append("=?");
            selectionArgs[i++] = Long.toString(threadId);
        }
        threadIdSelection = buf.toString();
        selectionBuilder.append(" AND (" + threadIdSelection + ")");
    }
    final Cursor c = SqliteWrapper.query(context, context.getContentResolver(), Mms.Inbox.CONTENT_URI, new String[] { Mms._ID, Mms.MESSAGE_ID }, selectionBuilder.toString(), selectionArgs, null);
    if (c == null) {
        return;
    }
    final Map<String, String> map = new HashMap<>();
    try {
        if (c.getCount() == 0) {
            if (callback != null) {
                callback.run();
            }
            return;
        }
        while (c.moveToNext()) {
            Uri uri = ContentUris.withAppendedId(Mms.CONTENT_URI, c.getLong(0));
            map.put(c.getString(1), AddressUtils.getFrom(context, uri));
        }
    } finally {
        c.close();
    }
    OnClickListener positiveListener = new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            for (final Map.Entry<String, String> entry : map.entrySet()) {
                MmsMessageSender.sendReadRec(context, entry.getValue(), entry.getKey(), status);
            }
            if (callback != null) {
                callback.run();
            }
            dialog.dismiss();
        }
    };
    OnClickListener negativeListener = new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (callback != null) {
                callback.run();
            }
            dialog.dismiss();
        }
    };
    OnCancelListener cancelListener = new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            if (callback != null) {
                callback.run();
            }
            dialog.dismiss();
        }
    };
    confirmReadReportDialog(context, positiveListener, negativeListener, cancelListener);
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) DialogInterface(android.content.DialogInterface) Cursor(android.database.Cursor) Uri(android.net.Uri) OnClickListener(android.content.DialogInterface.OnClickListener) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) MimeTypeMap(android.webkit.MimeTypeMap) OnCancelListener(android.content.DialogInterface.OnCancelListener)

Example 20 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project AndEngine by nicolasgramlich.

the class GenericInputDialogBuilder method create.

// ===========================================================
// Methods
// ===========================================================
public Dialog create() {
    final EditText etInput = new EditText(this.mContext);
    etInput.setText(this.mDefaultText);
    final AlertDialog.Builder ab = new AlertDialog.Builder(this.mContext);
    if (this.mTitleResID != 0) {
        ab.setTitle(this.mTitleResID);
    }
    if (this.mMessageResID != 0) {
        ab.setMessage(this.mMessageResID);
    }
    if (this.mIconResID != 0) {
        ab.setIcon(this.mIconResID);
    }
    this.setView(ab, etInput);
    ab.setOnCancelListener(this.mOnCancelListener).setPositiveButton(android.R.string.ok, new OnClickListener() {

        @Override
        public void onClick(final DialogInterface pDialog, final int pWhich) {
            final T result;
            try {
                result = GenericInputDialogBuilder.this.generateResult(etInput.getText().toString());
            } catch (final IllegalArgumentException e) {
                Debug.e("Error in GenericInputDialogBuilder.generateResult()", e);
                Toast.makeText(GenericInputDialogBuilder.this.mContext, GenericInputDialogBuilder.this.mErrorResID, Toast.LENGTH_SHORT).show();
                return;
            }
            GenericInputDialogBuilder.this.mSuccessCallback.onCallback(result);
            pDialog.dismiss();
        }
    }).setNegativeButton(android.R.string.cancel, new OnClickListener() {

        @Override
        public void onClick(final DialogInterface pDialog, final int pWhich) {
            GenericInputDialogBuilder.this.mOnCancelListener.onCancel(pDialog);
            pDialog.dismiss();
        }
    });
    return ab.create();
}
Also used : EditText(android.widget.EditText) AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener)

Aggregations

DialogInterface (android.content.DialogInterface)179 OnClickListener (android.content.DialogInterface.OnClickListener)179 AlertDialog (android.app.AlertDialog)118 View (android.view.View)45 SuppressLint (android.annotation.SuppressLint)36 TextView (android.widget.TextView)36 Intent (android.content.Intent)34 Context (android.content.Context)24 EditText (android.widget.EditText)22 Bundle (android.os.Bundle)21 LayoutInflater (android.view.LayoutInflater)16 Builder (android.app.AlertDialog.Builder)15 Paint (android.graphics.Paint)14 OnCancelListener (android.content.DialogInterface.OnCancelListener)12 KeyEvent (android.view.KeyEvent)12 Point (android.graphics.Point)11 AlertDialog (android.support.v7.app.AlertDialog)11 ContextThemeWrapper (android.view.ContextThemeWrapper)11 CompoundButton (android.widget.CompoundButton)11 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)11