Search in sources :

Example 1 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 2 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 3 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project Signal-Android by WhisperSystems.

the class WebRtcCallActivity method handleNoSuchUser.

private void handleNoSuchUser(@NonNull final WebRtcViewModel event) {
    // XXX Stuart added this check above, not sure why, so I'm repeating in ignorance. - moxie
    if (isFinishing())
        return;
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    dialog.setTitle(R.string.RedPhone_number_not_registered);
    dialog.setIconAttribute(R.attr.dialog_alert_icon);
    dialog.setMessage(R.string.RedPhone_the_number_you_dialed_does_not_support_secure_voice);
    dialog.setCancelable(true);
    dialog.setPositiveButton(R.string.RedPhone_got_it, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            WebRtcCallActivity.this.handleTerminate(event.getRecipient());
        }
    });
    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            WebRtcCallActivity.this.handleTerminate(event.getRecipient());
        }
    });
    dialog.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener)

Example 4 with OnClickListener

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

the class CryptoSettingsDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Bundle arguments = savedInstanceState != null ? savedInstanceState : getArguments();
    currentMode = CryptoMode.valueOf(arguments.getString(ARG_CURRENT_MODE));
    @SuppressLint("InflateParams") View view = LayoutInflater.from(getActivity()).inflate(R.layout.crypto_settings_dialog, null);
    cryptoModeSelector = (CryptoModeSelector) view.findViewById(R.id.crypto_status_selector);
    cryptoStatusText = (LinearViewAnimator) view.findViewById(R.id.crypto_status_text);
    cryptoModeSelector.setCryptoStatusListener(this);
    updateView(false);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(view);
    builder.setNegativeButton(R.string.crypto_settings_cancel, new OnClickListener() {

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

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

Example 5 with OnClickListener

use of android.content.DialogInterface.OnClickListener in project android_frameworks_base by ParanoidAndroid.

the class QuickSettings method showBugreportDialog.

private void showBugreportDialog() {
    final AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setPositiveButton(com.android.internal.R.string.report, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == DialogInterface.BUTTON_POSITIVE) {
                // Add a little delay before executing, to give the
                // dialog a chance to go away before it takes a
                // screenshot.
                mHandler.postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            ActivityManagerNative.getDefault().requestBugReport();
                        } catch (RemoteException e) {
                        }
                    }
                }, 500);
            }
        }
    });
    builder.setMessage(com.android.internal.R.string.bugreport_message);
    builder.setTitle(com.android.internal.R.string.bugreport_title);
    builder.setCancelable(true);
    final Dialog dialog = builder.create();
    dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
    try {
        WindowManagerGlobal.getWindowManagerService().dismissKeyguard();
    } catch (RemoteException e) {
    }
    dialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) AlertDialog(android.app.AlertDialog) Dialog(android.app.Dialog) OnClickListener(android.content.DialogInterface.OnClickListener) RemoteException(android.os.RemoteException)

Aggregations

OnClickListener (android.content.DialogInterface.OnClickListener)264 DialogInterface (android.content.DialogInterface)259 AlertDialog (android.app.AlertDialog)161 View (android.view.View)75 TextView (android.widget.TextView)52 Intent (android.content.Intent)44 SuppressLint (android.annotation.SuppressLint)41 Context (android.content.Context)35 AlertDialog (android.support.v7.app.AlertDialog)32 LayoutInflater (android.view.LayoutInflater)30 EditText (android.widget.EditText)30 Activity (android.app.Activity)27 Bundle (android.os.Bundle)25 OnCancelListener (android.content.DialogInterface.OnCancelListener)21 ImageView (android.widget.ImageView)17 Builder (android.app.AlertDialog.Builder)16 Dialog (android.app.Dialog)16 ProgressDialog (android.app.ProgressDialog)15 Paint (android.graphics.Paint)15 AdapterView (android.widget.AdapterView)15