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